error when using a mixed mode dll in a windows service

under the dot net 2.0 framework I get the following error when i use a mixed mode dll with in a vb.net windows service. System.BadImageFormatException: Invalid access to memory location. (Exception from HRESULT: 0x800703E6). This dll works fine if used in a vb.net standalone application. Any ideas what may be the cause



Answer this question

error when using a mixed mode dll in a windows service

  • MarkBuckland

    I tried moving the nonmanaged dependancies to the system directory but it did not resolve this issue. Infact if the nonmanaged dll's are missing i recece an exception telling me dot net could not find a module. This mixed mode dll does contain mfc, and this windows service ran fine under the 1.1 framework.
  • matttypething

    You might be missing the runtime support Dlls. If you're MFC and C++ you'll need the manifest stuff.

    http://msdn2.microsoft.com/en-us/library/ms235264.aspx



  • sirck

    Interesting I have found that this mixed mode dll will work in the service if its linked directly to the service. or if i pre load the assimbly with loadfrom. It seems to be some type of native vs managed load issue. I also get the same error when i try to use this dll in my webapp or webservice.

    System.BadImageFormatException: Invalid access to memory location. (Exception from HRESULT: 0x800703E6)


  • Giles Nutkins

    This is a win2003 system it also happens to be my development box so i do have all the proper dependancies, and the manifest file is properly embedded in my dll.
  • varadaraj

    Hi,

    I had similar sittuation, the trick was to add the nonmanaged dll to the system PATH. The problem (if I recall cofrrectly) was that my managed dll was copied and executed from some cashed .NET location, not from the directory where I compiled it, so it was not able to find my nonmanaged dll.

    Max



  • Glen Clark

    After opening a ticket with Microsoft we were able to determine the fault was in a third party component SQLITE. My solution was to recompile and integrate the binary into our project.
  • error when using a mixed mode dll in a windows service