Sign in to follow this  
Hermes

System.TypeLoadException

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this