Adding a WCF Service to a Project

I have a C # WinForms project that contains some WCF service definition files that I created in the project, adding standard classes (without using Add Item> WCF Service).

The project contains some dependencies that require me to create a project for x86 processors.

If I edit the app.config file using the WCF service configuration editor and try to use the "Create a new service ..." wizard, and then go to the project's EXE file (in the debug folder), I get an error message (which I read, because I am aiming for x86 processor):

Could not load file or assembly 'EXE_FILE_NAME' or one of its dependencies. An attempt was made to load a program with an incorrect format.

So, changing the target to all the CPUs, compiling the project again, and then again try to create the service in the WCF configuration editor, now I get another error:

Could not load file or assembly 'SOLUTION_NAME, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

(To clarify, I CAN still compile the project when setting up all the CPUs, but get a runtime error due to dependency)

Did anyone help me with this problem, so I can add the services defined in the app.config file using the wizards in the WCF configuration editor? (I think that if I add services to the WCF Service Configuration Editor when targeting all CPUs, I can make any changes after that, regardless of purpose)

+4
source share
1 answer

When debugging, review the details of the exception. From what you described, my hunch is that the assembly failed to load in the merge log because WCF service dependencies cannot be satisfied if you look at the default locations.

Say, for example, you are referring to MrCritter.MyService.dll, which defines a WCF service and has a dependency on something like log4net or nHibernate. While none of these dependencies flows into the WCF host (for example, returns ILog), yes, you can compile everything, but get a ReflectionTypeLoadException when trying to create an instance of a service class if these dependencies are not found somewhere in it (for example, in executable directory, in the GAC, etc.).

0
source

All Articles