locked
WCF Client call from Test App throws exception RRS feed

  • Question

  • Hello,

    I have a WCF service hosted as a Windows service and a WCF client that calls the methods in the service using a Channel Factory.  My WCF client was set up as a console application and therefore built to a .exe file.  I have a test app that creates a new process and runs this .exe file passing it an argument -- and this works fine.  I also have a static method in the WCF client that takes 1 string parameter as input.  I am trying to call this method from another test app, passing it the same string parameter that I passed to the .exe version.  When I make this call I get an exception that says:

    An attempt was made to load a program with an incorrect format.

    I see a lot of 64-bit/32-bit problems relating to this when searching, but this is not my case, as nothing I have is 64-bit.

    I'm not sure what else could be causing this...

    Monday, April 19, 2010 7:23 PM

Answers

  • Hi Michael,

    If there is only managed assemblies here, there hasn't any obvious potential issues besides the 32/64 bit compiling one. As you mentioned that the problem went away after you migrate from VS 2010 BETA to RTM, so far I can only tell that the cause is possibly related to the compilation of the beta version VS2010. If you have interesting, you can try using reflector or some disassemble tool to inspect the PE header and .NET managed headers of the assemblies(built by the beta verion and RTM) to see whether there is any obvious difference).



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Michael_86 Monday, April 26, 2010 1:55 PM
    Monday, April 26, 2010 2:52 AM

All replies

  • Check the input data format of wcf client(Console app)..that may be mismatched
    Regards, Nakul
    Tuesday, April 20, 2010 4:35 AM
  • Hi Michael,

    If there is no 32/64 bit issue, are all those exe programs involved here .NET managed application(is any of them native win32 program)?

    Also, would you show some code fragment to us about how you call the static method within the test program(is it also a .NET application)? To call the static method in your WCF client exe, you will need to first add reference to it in your test application.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, April 20, 2010 7:29 AM
  • All of the assemblies are .NET managed applications.  One of them does make use of a dll import:

    [DllImport("kernel32.dll")]
    private static extern uint GetProcessVersion(uint ProcessId);

    but commenting that out didn't solve the problem.  Also, the reference was added in the test project to the WCF client.  Here is the static method call from the test project:

    static void Main(string[] args)
    {
    WCFClientNamespace.WCFClient.StaticMethod("inputString");
    }
    All that said, I updated from the Beta-2 version of VS2010 to the release version and the call now works.  Any ideas as to what may have been causing this?
    Tuesday, April 20, 2010 1:11 PM
  • Hi Michael,

    If there is only managed assemblies here, there hasn't any obvious potential issues besides the 32/64 bit compiling one. As you mentioned that the problem went away after you migrate from VS 2010 BETA to RTM, so far I can only tell that the cause is possibly related to the compilation of the beta version VS2010. If you have interesting, you can try using reflector or some disassemble tool to inspect the PE header and .NET managed headers of the assemblies(built by the beta verion and RTM) to see whether there is any obvious difference).



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Michael_86 Monday, April 26, 2010 1:55 PM
    Monday, April 26, 2010 2:52 AM