Click here to Skip to main content
15,889,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Just to showcase problem I have written a simple DLL x64 of "Hello world" changed its property to CLR and Calling its Function from an Exe which is also x64 and property Changed to CLR.

But My exe prints the Output "Hello World" and crashes every time and gives FAULT Module Name KERNELBASE.dll.

When I change Property of both to NO CLR it works perfectly fine. This happens only for x64 application not observed in x86 program.

I am using Visual Studio 2017 on Windows Server 2012.

It will be very helpful if someone can guide me to correct direction.

Details of App Crash

Problem Event Name: APPCRASH
  Application Name: consuming_using_clr.exe
  Application Version:  0.0.0.0
  Application Timestamp:    5b42fff3
  Fault Module Name:    KERNELBASE.dll
  Fault Module Version: 6.3.9600.17055
  Fault Module Timestamp:   532954fb
  Exception Code:   c0020001
  Exception Offset: 0000000000005bf8
  OS Version:   6.3.9600.2.0.0.16.7
  Locale ID:    1033
  Additional Information 1: 8e72
  Additional Information 2: 8e72455f15a8480830570fcb3c4abf60
  Additional Information 3: f8d5
  Additional Information 4: f8d519c5149c6c561af747d4db7e910a

DLL dot.h file

// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the DLLWINDOWSDESKTOPWIZARD_EXPORTS
// symbol defined on the command line. This symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// DLLWINDOWSDESKTOPWIZARD_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef DLLWINDOWSDESKTOPWIZARD_EXPORTS
#define DLLWINDOWSDESKTOPWIZARD_API __declspec(dllexport)
#else
#define DLLWINDOWSDESKTOPWIZARD_API __declspec(dllimport)
#endif
#using<System.dll>
#include<iostream>
using namespace System;
using namespace std;
// This class is exported from the Dll_windows_desktop_wizard.dll
class DLLWINDOWSDESKTOPWIZARD_API CDllwindowsdesktopwizard 
{

public:
    CDllwindowsdesktopwizard(void);
    ~CDllwindowsdesktopwizard(void);
    void helloworld();

};

*DLL DOT CPP File *

// Dll_windows_desktop_wizard.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "Dll_windows_desktop_wizard.h"


// This is the constructor of a class that has been exported.
// see Dll_windows_desktop_wizard.h for the class definition

CDllwindowsdesktopwizard::CDllwindowsdesktopwizard(void)
{
}

CDllwindowsdesktopwizard::~CDllwindowsdesktopwizard(void)
{
}

void CDllwindowsdesktopwizard::helloworld()
{
    Console::WriteLine("Hello World");
}

EXE Calling DLL Function

#include<iostream>
#include "Dll_windows_desktop_wizard.h"
using namespace System;

int main()
{
    CDllwindowsdesktopwizard lv_obj;
    lv_obj.helloworld();
    return 0;
}


What I have tried:

I have scanned Server but didn't find any corrupt file.
Posted
Comments
Jochen Arndt 12-Jul-18 7:16am    
Exception (NT status code) 0xC0020001 is RPC_NT_INVALID_STRING_BINDING / "The string binding is invalid".

I'm not so familiar with CLI. Maybe the article Best gotchas of C++/CLI can give you some insight.
Member 13703287 12-Jul-18 8:18am    
After you said i started removing warning from my exe
warning:Calling managed 'DllMain': Managed code may not be run under loader lock,including the DLL entrypoint and calls reached from the DLL entrypoint
and got #pragma unmanaged while googling. Added it in dllmain.cpp and it worked.
Thank You for the Suggestion.:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900