I have a core project that stores static data, I use it in the data preoctc and I get this error System.TypeInitializationException: 'The type initializer for 'ERP.Core.Constants.CoreDefaultValues' threw an exception.'
Code Data
builder.HasData(new CashFlowItem
{
Id = CoreDefaultValues.DefaultExpenseCashFlowItemId,
Name = "Income",
Description = "Income",
BelongTo = BelongTo.OperatingActivity,
ReferenceType = ReferenceType.CatalogCashFlowItem
}, new CashFlowItem
{
Id = CoreDefaultValues.DefaultExpenseCashFlowItemId,
Name = "Expense",
Description = "Expense",
BelongTo = BelongTo.OperatingActivity,
ReferenceType = ReferenceType.CatalogCashFlowItem
});
Code Core class CoreDefaultValues
public static class CoreDefaultValues{
public static Guid DefaultIncomeCashFlowItemId = new("a0ce69fc-dac3-4d05-8084-82edb1478be6");
public static Guid DefaultExpenseCashFlowItemId = new("CA32B849-C4FA-476D-AC29-D6EFE2848F74");
}
I tried changing formats
new Guid(CoreDefaultValues.DefaultExpenseCashFlowItemId.ToString(("D"))),
but nothing helped
all exeption
add all field in class
public static class CoreDefaultValues
{
public const string AdminRoleName = "Admin";
public const string Version = "1.0";
public static System.Guid ApplicationUserId = new System.Guid("0F235EA1-D3A8-4894-94A0-7E7A3081EC12");
public static System.Guid AccountId = new System.Guid("0F235EA1-D4A8-4894-94A0-7E7A3081EC12");
public static System.Guid DefaultProductId1 = new System.Guid("77E46C72-B10E-4F3E-AAB2-9079F197698C");
public static System.Guid DefaultProductId2 = new System.Guid("049BE269-1A0A-4F70-BB46-482782808378");
public static System.Guid DefaultWarehouseId1 = new System.Guid("049BE269-1A0A-4F70-BB46-482782804378");
public static System.Guid DefaultCustomerInvoice = new System.Guid("049BE269-1A3A-4F70-BB46-482782804378");
public static System.Guid DefaultIncomingBankPayment = new System.Guid("046BE269-1A3A-4F70-BB46-482782804378");
public static System.Guid WorkScheduleId = new System.Guid("da6a28fc-b7bc-4cda-ba63-c236daaca8ee");
public static System.Guid CompanyId2 = new("cd0cc42f-ea18-4538-893b-0f90001d48c1");
public static System.Guid CustomerId2 = new("90609e9f-8aa6-4528-b5f2-73dae301ec5c");
public static System.Guid VendorId2 = new("6e8b2202-0060-4366-ba79-fe5ec0b33a11");
public static System.Guid ContractId1 = new("24b3f4a6-9c94-4d67-a9f8-9ca50284ce3b");
public static System.Guid ContractId2 = new("80267ab7-244a-4ad5-91e6-2e2a6831968f");
public static System.Guid WarehouseId2 = new("2c89b195-e04e-4945-a4d4-d9a1f20fa1cc");
public static System.Guid CashId = new("55f9e845-910b-4294-a77d-b487ff314076");
public static System.Guid BaseDocumentId = new("ad34d649-5b1c-4c05-9841-7498aaae7ae5");
public static System.Guid IncomeItemId = new("8811ac5b-ae3e-4928-ad15-6a03ac927099");
public static System.Guid ProductId1 = new("77E46C72-B10E-4F3E-AAB2-9079F197698C");
public static System.Guid ProductId2 = new("049BE269-1A0A-4F70-BB46-482782808378");
public static System.Guid DivisionId = new System.Guid("046BE859-1A3A-4F70-BB46-482782804378");
public static System.Guid CompanyId1 = new System.Guid("56E46C72-B10E-4F3E-AAB2-9079F197698C");
public static System.Guid EmployeeId = new System.Guid("b26831a2-67c5-46dd-8e2d-3181ba06f84a");
public static System.Guid BankAccountId = new System.Guid("b29561a2-67c5-46dd-8e2d-3181ba06f84a");
public static System.Guid BankAcquirerId = new System.Guid("b36561a2-67c5-46dd-8e2d-3181ba06f84a");
public static System.Guid CashRegisterId = new System.Guid("b36561a2-67c5-43dd-8e2d-3181ba06f84a");
public static System.Guid VendorInvoiceId = new System.Guid("b36561a2-67c5-49ad-8e2d-3181ba06f84a");
public static System.Guid VendorId = new System.Guid("b36561a2-62c5-49ad-8e2d-3181ba06f84a");
public static System.Guid BankId = new System.Guid("0b7167ab-9615-41d8-a2f0-c2f446d1c158");
public static System.Guid CustomerId = new System.Guid("b36561a2-62c5-49ad-8e2d-3156ba06f84a");
public static System.Guid AssemblyDisassemblyOrderId1 = new System.Guid("8607ec1c-f053-45ac-8e34-e44a2326d931");
public static System.Guid DefaultIncomeItemId = new System.Guid("d1b1b1b1-2112-40cf-b160-9b54e2a2f172");
public static System.Guid DefaultExpenseItemId = new System.Guid("e2c2c2c2-2112-40cf-b160-9b54e2a2f172");
public static System.Guid DefaultCurrencyId = new System.Guid("897e9ed2-485f-11e8-965c-5404a6690035");
public static System.Guid DefaultIncomeCashFlowItemId = new System.Guid("a0ce69fc-dac3-4d05-8084-82edb1478be6");
public static System.Guid DefaultExpenseCashFlowItemId = new System.Guid("ca32b849-c4fa-476d-ac29-d6efe2848f74");
public static System.Guid AnalyticsTypeOfIncomeExpenseItemId = new System.Guid("584688b4-728b-4c50-a3a1-f6e3ee54c5ba");
public static System.Guid AnalyticsTypeOfIncomeExpenseItemId1 = new System.Guid("484688b4-728b-4c50-a3a1-f6e3ee54c5ba");
public static System.Guid ApplicationRoleId = new System.Guid("d33c7d92-5ac0-4375-a050-6aaf48a65574");
public static System.Guid ApplicationUserId1 = new System.Guid("b0c720e5-6905-4845-9722-92bfd75436fa");
public static System.Guid ApplicationUserSettingsId = new System.Guid("3a4b3507-9adc-4905-881a-52221471ca76");
public static System.Guid ArApOffsetId = new System.Guid("d52688c4-0d25-428c-b356-069f55ca3089");
public static System.Guid ArApOffsetId1 = new System.Guid("fec54b03-b649-4d8c-b520-382503416f89");
public static System.Guid DivisionId1 = new System.Guid("fec54b03-b649-4d8c-b520-382403216f99");
public static System.Guid ApplicationUserId2 = new System.Guid("b87bfc24-2ce5-4511-b4f2-a223c1ff1371");
public static System.Guid ApplicationUserId3 = new System.Guid("d583cc23-20c5-4889-84bf-7ed6b6498000");
public static System.Guid ArApOffset2 = new System.Guid(" 77fadadb-6c6b-4997-a90c-6e42f285ab8b");
public static System.Guid ArApWriteOff2 = new System.Guid ("9b37cd3f-aef8-4b16-ba7a-9a2516d48a68");
public static System.Guid AssemblyDisassemblyOfGood1 = new System.Guid ("197d7dfc-c0fd-4e2e-8644-4c535ff239d8");
public static System.Guid UnitId = new System.Guid ("e0368b36-7699-4e01-8cb3-31433b5a1ab4");
public static System.Guid AssemblyDisassemblyOfGoodGood1 = new System.Guid(" 8b56af46-f96c-4eef-b9a6-11eb25e5694d");
public static System.Guid AssemblyDisassemblyOfGoodGood2 = new System.Guid(" 9b56af46-f96c-4eef-b9a6-11eb25e5694d");
public static System.Guid AssemblyDisassemblyOfGoodId = new System.Guid("fdb21ee1-379a-4e83-83a8-f962da4ef614");
public static System.Guid AssemblyDisassemblyOrderGoodId = new System.Guid("4bced959-03b8-4ce9-8ce0-522a39807952");
public static System.Guid DefaultWarehouseId2 = new System.Guid ("8a5cf88f-4aa0-4cc1-b5ad-9abe0018d4a0");
public static System.Guid BaseDocumentAtId = new System.Guid("a053e58a-f41d-444f-a357-4b8b119d1960");
public static System.Guid VendorCustomerId = new System.Guid("44b67059-584c-4370-9a60-c16d2c026aaa");
public static System.Guid BankAccountVendorCustomerId = new System.Guid ("7b43e128-5f6e-4487-937b-5c78eff598df");
public static System.Guid BillOfMaterialId = new System.Guid ("ed0bab1f-98ae-4576-8124-9f5b17f8a0ba");
public static System.Guid CalendarDayId = new System.Guid ("d3c0d2c1-fbf8-418a-b3f7-e2d872aacc36");
public static System.Guid CalendarDayId1 = new System.Guid("d2c0d2c1-fbf8-418a-b3f7-e2d872aacc36");
public static System.Guid CashFlowItemId = new System.Guid("ecd168e9-03fb-448b-afb5-da5413d4a805");
public static System.Guid AnalyticsTypeOfActivePassiveItemId = new System.Guid("4d5b36c9-22e0-4326-bfba-c50d412edc8a");
public static System.Guid CategoryOfFixedAssetsId = new System.Guid("dbbb277a-8a0e-4f35-8902-48e497d004df");
public static System.Guid TaxGroupId = new System.Guid("dd99aa4b-c4c6-493d-acbb-b647f7c71178");
public static System.Guid AccountId1 = new System.Guid ("333eeb4f-1f7f-4047-946c-1daa0c28aa4b");
public static System.Guid ActivePassiveItemId = new System.Guid ("bd262138-aa26-4629-885a-840b28910870");
public static System.Guid CommodityWaybillId = new System.Guid("69c6d419-6d29-4124-aeb9-965cda71fa20");
public static System.Guid CommodityWaybillInformationId = new System.Guid("bf69ba90-2b7c-449b-b902-7b0f9b60c72d");
public static System.Guid CommodityWaybillProductId = new System.Guid("5f3497b0-ee9c-4a5b-ac86-4434696185df");
public static System.Guid CompanyCashBoxId = new System.Guid("b6fff3ae-01d 1-47cb-b789-8f 3878c9552f");
public static System.Guid ConsumptionOrderId = new System.Guid("b54f4079-2f76-4a00-a810-d757c7baecf8");
public static System.Guid ProductId = new System.Guid ("5d84c5fe-de19-469a-acd7-52a6525bdfda");
public static System.Guid ConsumptionOrderGoodId = new System.Guid("de5b29b0-6d 63-44e3-abd4-c2a2ec8c8f6d");
public static System.Guid CountryId = new System.Guid("f689dcb0-40ba-4451-ba91-03f5e41ab767");
public static System.Guid DeductionId = new System.Guid("11458640-e97b-4531-b355-ac13a863323c");
public static System.Guid DeliveryMethodId = new System.Guid("e696d028-b5cb-4c84-9a71-0b99966e222f");
public static System.Guid DepreciationChargeId = new System.Guid("dc917185-1bff-42b9-9b33-548b63d23c08");
public static System.Guid DistributionOfLandedCostId = new System.Guid("5c8cbe1d-bd2e-4760-84c5-16b2e0660214");
public static System.Guid DistributionOfLandedCostDocumentVendorInvoiceId =
new System.Guid("f03fcec1-f857-4931-892f-045c77e3cf95");
public static System.Guid DistributionOfLandedCostExpenseId = new System.Guid("0ab16ddb-dfa9-46da-863f-68f07bab2459");
public static System.Guid DistributionOfLandedCostGoodId = new System.Guid("6716b004-fdec-4031-8a11-7227a8d49ea9");
public static System.Guid CompanyId = new System.Guid ("0a30637e-6156-4c85-8e38-86c8ffdb30a3");
public static System.Guid VehicleId = new System.Guid("454d39ec-1f4c-4ecb-913a-6d6ac389111e");
public static System.Guid DriverId = new System.Guid ("d0753a9a-d6c8-454e-829b-171e4d539d31");
public static System.Guid EmployeeDismissalId = new System.Guid ("c5625b8a-9a4b-4a31-8d96-38949621eed6");
public static System.Guid PersonId = new System.Guid("0448b082-52db-486e-9b61-aecf3bc79d84");
public static System.Guid PositionId = new System.Guid("8e14b054-f36f-4f94-8d73-615a41a61d92");
public static System.Guid EmployeeHireId = new System.Guid("cda494ed-f914-4548-8d14-dc19cfdda3f2");
public static System.Guid HeadEmployeeId = new System.Guid(" 7092684d-b164-43ba-9775-bc0320b96761");
public static System.Guid AuthorId = new System.Guid ("f85e248f-f5f9-47ed-9eea-ce46094f4aa9");
public static System.Guid CreatedUserId = new System.Guid("c1cb55a2-8119-42a4-a667-2417294a8370");
public static System.Guid EmployeeTransferId = new System.Guid("1ee42b5b-e4a1-484e-b77b-7e4bb0729c05");
public static System.Guid EnterOfSettlementsBalanceId = new System.Guid("8ea72f4a-5c7c-4de5-aece-ee1c6cbee0e7");
public static System.Guid EnterOfSettlementsBalanceGoodId = new System.Guid("3e957f6f-f5c1-476d-9f3d-c946bb0c7573");
public static System.Guid CurrencyId = new System.Guid("3e957d6f-f5c1-476d-1f4d-c946bb0c7573");
public static System.Guid ExchangeDifferenceCalculationId = new System.Guid("93b76a86-ddf8-4e68-8295-0eb4ed086713");
public static System.Guid AnalyticsTypeOfIncomeId = new System.Guid("43ea078b-606d-4b30-8128-41cecb87a046");
public static System.Guid ExpenseItemId = new System.Guid("906c067e-b0a1-403e-9302-b31d03cf1b8f");
public static System.Guid FeatureId = new System.Guid("a526e9f1-6724-4562-82e6-adb9b758d4f0");
public static System.Guid FixedAssetId = new System.Guid("b43a6f3e-6394-4527-83ad-5e331792ae40");
public static System.Guid FixedAssetInitialRecognitionId = new System.Guid("95a1b41d-7bfb-4174-89a0-84554ced2b85");
public static System.Guid FixedAssetInitialRecognitionGoodId = new System.Guid("04007529-9a82-4bdf-911b-846f5005465d");
public static System.Guid FixedAssetTransactionHistoryId = new System.Guid("fc1852df-d711-4720-94c7-739d8ed80109");
public static System.Guid GoodsRegradingId = new System.Guid("a4d0e61a-702a-4fcf-9fce-5a9f76aaba9f");
public static System.Guid GoodsRegradingGoodPostingId = new System.Guid("4cfd26ea-3a88-4497-9f52-0d8378ecc876");
public static System.Guid GoodsRegradingGoodUnpostingId = new System.Guid("9738668a-977f-4216-a226-6d9127c9e73e");
public static System.Guid GoodsTransferOrderId = new System.Guid("7669fc3c-c36d-45ec-b252-ced531fd5ef6");
public static System.Guid GoodsTransferOrderGoodId = new System.Guid("fc0cc7d1-4b55-41a0-b2a2-77cebbce14cd");
public static System.Guid ImportId = new System.Guid("997cb61c-0b1b-4e7b-9d10-1dbc3cb2ba32");
public static System.Guid ImportAdditionalDocumentId = new System.Guid("33c9f32b-f193-4b50-bf3c-b8f2f7ccff72");
public static System.Guid AccountAnalyticId = new System.Guid("2c7a5685-0b9f-49a6-9189-3c47acb6c59b");
public static System.Guid ImportCustomsCostId = new System.Guid("7744e1ac-75b5-4b1e-9062-9026ea8ffc0d");
public static System.Guid ImportExciseDutyId = new System.Guid("7731d59f-d0fa-477f-b044-74d50c0ce884");
public static System.Guid ImportImportTaxId = new System.Guid("86654949-a56e-4cb1-ab23-4a96e5de64ac");
public static System.Guid? ContractId = new System.Guid("2a772c6e-bbd2-46df-981b-c4a84f8a0bd5");
public static System.Guid ImportVatId = new System.Guid("97e77f38-daf4-425e-9807-61a23e3d71cf");
public static System.Guid MaterialAndWorkId = new System.Guid("f90af516-4e21-4638-acf9-6792816207b5");
public static System.Guid PriceTypeId = new System.Guid("ede7fe26-1b48-418e-9ea8-92b7e259f51f");
public static System.Guid ProductBatchId = new System.Guid("9ed5de81-9b46-47d3-b8ac-b6b752c2ff75");
public static System.Guid ProductionId = new System.Guid("2a6bbf9a-0a00-492a-97e2-b07e08dc5cf1");
public static System.Guid VariantId = new System.Guid("d8eb3e17-0844-4ece-9a76-daa5f192faf6");
public static System.Guid ProductionManufacturedProductId = new System.Guid("d8b4f162-600c-4239-a1a1-120b5b97463e");
public static System.Guid ProductionMaterialAndWorkId = new System.Guid("74d27375-6630-42fd-8cb4-67ca634225a1");
public static System.Guid ProductPricingId = new System.Guid("989083d4-5b99-479f-9cdf-14f9862330df");
public static System.Guid ProductPricingGoodId = new System.Guid("ceda7af9-1faa-4fe0-806a-6aa3c77097e2");
public static System.Guid PurchaseOrderId = new System.Guid("a74c15ac-965a-4364-aff5-51f9cd8d74d4");
public static System.Guid AccountingManualTransactionId = new System.Guid("32cbf1bb-083b-4eb3-ab4f-b534f1d193f6");
public static System.Guid PurchaseOrderGoodId = new System.Guid("4a8a78ba-7e75-49d5-809f-326d75caf818");
public static System.Guid PurchaseOrderPaymentOffsetId = new System.Guid("9725fd34-ae2e-420f-88ca-179703b6fd21");
public static System.Guid AccountingManualTransactionTransactionId =
new System.Guid("6a0380db-e166-4ad2-a411-007ba8d3cb35");
public static System.Guid ReturnOfGoodsFromCustomerId = new System.Guid("e31d9e1d-5a1b-4fff-9f51-a9ca6ce8239d");
public static System.Guid ReturnOfGoodsFromCustomerGoodId = new System.Guid("700f9e93-3897-4e6f-809e-dd5c7eb2341e");
public static System.Guid AcquiringOperationId = new System.Guid("83ce9cd1-7b0f-4178-949d-6b25154555f0");
public static System.Guid AccrualId = new System.Guid("a7eb53a3-5e38-447f-9813-c1de87492c9b");
public static System.Guid ReturnOfGoodsFromVendorId = new System.Guid("57b54627-7c6d-40a2-a9f8-578ba1e3887f");
public static System.Guid ReturnOfGoodsFromVendorGoodId = new System.Guid("6d39c320-5993-4125-a3e2-0e7405ff66fa");
public static System.Guid SalaryAccrualId = new System.Guid("817e10fd-9d0b-443d-82fd-183a2b308d7f");
public static System.Guid SalaryAccrualPersonId = new System.Guid("265db6e3-8567-42dd-91b8-7571ad20a1ab");
public static System.Guid SalesOrderId = new System.Guid("4de4397f-ac2f-4362-b23e-fd0ce4960431");
public static System.Guid SalesOrderPaymentOffsetId = new System.Guid("97b11e9a-9b35-4017-bec0-752d9890fa8d");
public static System.Guid SpecificationId = new System.Guid("fc6f37cd-b5dd-416a-a8b6-e64143a8444a");
public static System.Guid SpecificationIncludedProductId = new System.Guid("75bd8d57-56b7-4eff-b506-4d962d8742d6");
public static System.Guid StocktakingId = new System.Guid("5479ab3c-a4ad-411d-ac7c-d74140d75f90");
public static System.Guid StocktakingGoodId = new System.Guid("6122b784-4b38-44a7-b79d-7abbeb8fb381");
public static System.Guid TransferOfGoodId = new System.Guid("51776472-2afd-419e-bfec-eb6b2c35c0a9");
public static System.Guid WithholdingTaxRateId = new System.Guid("bb658d3e-9123-49bc-bd99-93af16b42e0e");
public static System.Guid TransferOfGoodGoodId = new System.Guid("4a53f63b-6b41-482f-bdd7-9fe01d91af66");
public static System.Guid VatArticleId = new System.Guid("95cbac8e-b02e-4b9a-aad1-33c14b639b55");
public static System.Guid VendorInvoicePaymentOffsetId = new System.Guid("2c00b2f3-7b7c-4601-a823-b2a041cb388f");
public static System.Guid VendorInvoiceServicesAndAssetGoodId = new System.Guid("e833d5fd-848c-497e-9ae0-7a5bbbbc0fe9");
public static System.Guid VendorInvoiceServicesAndAssetId = new System.Guid("719ea7eb-95e7-4d55-8da9-06dbea1d70fa");
public static System.Guid VendorInvoiceServicesAndAssetsPaymentOffsetId =
new System.Guid("1fc8ea71-dd68-4552-86fa-d20912f8e2bd");
public static System.Guid VendorItemId = new System.Guid("20223d7d-761b-469b-8cec-3e6cab601790");
public static System.Guid WriteOffGoodId = new System.Guid("e754796b-60f0-413e-82ee-cf355d6f8b8f");
public static System.Guid WriteOffGoodGoodId = new System.Guid("d9c548b5-a8a6-45c2-bbe2-30f79ae6f590");
public static System.Guid IncomeCashFlowItemId = new System.Guid("c9c548b5-a8a6-45c2-bbe2-30f79ae6f590");
//Seed Old
public static Guid CurrencyUSD = new("9ca042d1-4d46-11e8-80c4-000c29a07c37");
public static Guid CurrencyEUR = new("d76b5989-8904-11e8-80c7-000c29a07c37");
public static Guid CurrencyGBP = new("6447f8a9-f6d5-11e8-843d-000c29b16d56");
public static Guid CurrencyCHF = new("d28f037b-9d6f-11e8-80da-000c29a07c37");
public static Guid CurrencyRUB = new("e6c1743c-8904-11e8-80c7-000c29a07c37");
public static Guid CurrencyGEL = new("e2c1743c-8904-11e8-80c7-000c29a07c37");
public static Guid AdminRoleId = new("ED667DBD-ADEE-42B4-9499-82980F333690");
public static Guid UserRoleId = new("C0AECF48-8EFB-4887-AF3F-BC6A56910BE4");
public static Guid AdminUserId = new("0F235EA1-D3A8-4894-94A0-7E7A3081EC12");
}
Two of the GUIDs are invalid. The actual full exception text shows the actual location of the error.
I put the static class in a separate file and tried to access one of the fields :
Console.WriteLine(CoreDefaultValues.ApplicationUserId);
The exception I got was :
Unhandled exception. System.TypeInitializationException: The type initializer for 'CoreDefaultValues' threw an exception.
---> System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid.GuidResult.SetFailure(Boolean overflow, String failureMessageID)
at System.Guid.TryParseExactD(ReadOnlySpan`1 guidString, GuidResult& result)
at System.Guid.TryParseGuid(ReadOnlySpan`1 guidString, GuidResult& result)
at System.Guid..ctor(String g)
at CoreDefaultValues..cctor() in C:\Projects\Work\ARC\CoreDefaultValues.cs:line 76
--- End of inner exception stack trace ---
at Program.<Main>$(String[] args) in C:\Projects\Work\ARC\Program.cs:line 1
This says there's a FormatException
at line 76
CompanyCashBoxId = new System.Guid("b6fff3ae-01d 1-47cb-b789-8f 3878c9552f");
That string contains spaces between the letters and can't be parsed as a GUID.
After fixing this the code fails at line 79, another invalid GUID "de5b29b0-6d 63-44e3-abd4-c2a2ec8c8f6d"