Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create dll based on 3rd dll #93

Closed
guzuomuse opened this issue Feb 12, 2019 · 3 comments
Closed

create dll based on 3rd dll #93

guzuomuse opened this issue Feb 12, 2019 · 3 comments
Labels

Comments

@guzuomuse
Copy link

i have created a dll with 3rd library: Rabbitmq.Client(.dll)

if a function return something without facilities reference to rabbitmq . everything goes well,but when i use some function from rabbitmq.client.dll; the function can't not run as expect;
example code:

	[return: MarshalAs(UnmanagedType.LPWStr)]
        [DllExport]
        public static string test_string([MarshalAs(UnmanagedType.LPWStr)]string content)
        {
            //var factory = new ConnectionFactory() { HostName = "localhost", UserName = "test", Password = "test" };  // here is the question, if i comment it , it can return content as expect,but uncomment,the exported dll will crash. 
            return content + "----from-c_sharp-----no--problem!";

        }

anybody can give me some tips ,why this occurs? how to solve this? many thanks!

@3F
Copy link
Owner

3F commented Feb 12, 2019

Similar to #84 (continues #83). Try to debug at runtime. Mixed mode for debugger with attaching to process.

#84 (comment)

your problem may be exactly from logic of using your mentioned "the Neural Networks" library: incorrect initialization, invalid data, or even null and the related unhandled exception from managed side, stack corruption, stack overflow, and lot of other bugs.

@3F 3F added the question label Feb 12, 2019
@3F
Copy link
Owner

3F commented Feb 12, 2019

Also note, for stack problems you need to check required calling convention and try to start from basic signature without marshaling. Usually, I recommend only IntPtr because of more control. Well, it's my prefer.

But in general, your ConnectionFactory can do anything like "Neural Networks" library from #84.

Also try to isolate or catch something (about exceptions, start here #85). How about to reproduce an invoking from your trivial unmanaged side? C++ complete example see in related repo.

@guzuomuse
Copy link
Author

@3F
sorry for late reply.
In my case,after debugging, i found the reason was that i should copy the 3rd dlls to some special place, and the it worked;
thanks for this library man!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants