Jump to content
  • Advertisement
Sign in to follow this  
Hermes

System.TypeLoadException

This topic is 4396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Since i didn't find any relevant information about C++ win32 services, i put the core functions(C/C++ based) into a DLL and loaded them in a C# service. Here is the error i get when i try to start the service. "An unhandled exception of type 'System.TypeLoadException' occurred in Unknown Module. ............................................................. because the method InitServiceWrapper has no RVA. " I really don't know how to get arround this. Below is the C++ function i try to call from my service. It is supposed to load a driver

void InitService()
{

    //
    // open the device
    //
    
    if((hDevice = CreateFile( "\\\\.\\DRV",
            GENERIC_READ | GENERIC_WRITE,
            0,
            NULL,
            CREATE_ALWAYS,
            FILE_ATTRIBUTE_NORMAL,
            NULL)) == INVALID_HANDLE_VALUE) {
                
        errNum = GetLastError();

        if (errNum != ERROR_FILE_NOT_FOUND) {

            printf("CreateFile failed!  ERROR_FILE_NOT_FOUND = %d\n", errNum);

            return ;
        }
       
        //
        // The driver is not started yet so let us the install the driver.
        // First setup full path to driver name.
        //

        if (!SetupDriverName(driverLocation)) {

            return ;
        }
        
        if (!ManageDriver(PARANOID_DEVICE_NAME,
                          (LPCSTR)driverLocation,
                          DRIVER_FUNC_INSTALL
                          )) {

            printf("Unable to install driver. \n");

            //
            // Error - remove driver.
            //

            ManageDriver(PARANOID_DEVICE_NAME,
                         (LPCSTR)driverLocation,
                         DRIVER_FUNC_REMOVE
                         );
            
            return;
        }
        
        

   		
			
  }
 
}



Thanks !

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hermes,
i think you posted the wrong snippet of code here. The error is likely to be found in the InitServiceWrapper() method. The border line between managed an unmanaged implementation is of interest here. Please post some more of the "plumbing" code.

cheers,
simon

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!