Я только что создал сервисную библиотеку wcf и использую простое консольное приложение для подключения к ней. Однако в тот момент, когда я запускаю свое консольное приложение, открывается узел службы wcf и показывает следующую ошибку:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\uop\source\repos\WPF\APPONE\APPONE.Service\bin\x86\Debug\APPONE.Service.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'file:///C:\Users\amosa\source\repos\WPF\APPONE\APPONE.Service\bin\x86\Debug\APPONE.Service.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Я убедился, что все мои приложения работают на x86.
Я пытался увидеть если это проблема в моей программе, но она даже не достигает первой точки отладки в моей программе:
static void Main(string[] args)
{
// Step 1: Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8733/APPONE/");
// Step 2: Create a ServiceHost instance.
ServiceHost selfHost = new ServiceHost(typeof(DocumentType), baseAddress);
try
{
selfHost.AddServiceEndpoint(typeof(IDocumentType), new WSHttpBinding(), "DocumentType");
// Step 4: Enable metadata exchange.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
// Step 5: Start the service.
selfHost.Open();
Console.WriteLine("The service is ready.");
// Close the ServiceHost to stop the service.
Console.WriteLine("Press <Enter> to terminate the service.");
Console.WriteLine();
Console.ReadLine();
selfHost.Close();
}
catch(Exception e)
{
Console.WriteLine("An exception occurred: {0}", e.Message);
selfHost.Abort();
}
}