简体   繁体   中英

Calling unmanaged code from ASP.NET in IIS7

I call a DLL in ASP.NET a DLL that is written in C++. When running it into IIS 7, The pool (w3wp.exe) crash and the "just in time debugging window" open.

I do many tracing and I found that crash happen when calling any function (in the unmanaged DLLs) that have a "out string" parameter (or return a string value).

I saw on the web than many people have this problem with their DLL (C, Delphi, VB6). But no answer. so I call experts!

How can I call these functions so IIS 7 process it without error ?

cas sakal

您应该将StringBuilder用于互操作字符串输出参数:

  [MarshalAs(UnmanagedType.LPStr)] StringBuilder myString

It may not be possible. COM provides an interface specification, but not a guarantee that the caller be able to use the interface correctly. Unless the COM object exposes methods which are automatically marshalable by the COM subsystem (eg: automation compatible), you may not be able to use them. It's easily possible to write a C++ COM object which cannot be directly accessed out-of-process, or by any language other than C++.

You may be able to write some custom marshaling code to make it work, but I wouldn't assume it will work directly. If the types are simple/direct enough, there may be some built-in marshal attributes to make it work; I don't have a lot of knowledge in this area, though, so hopefully other people can help out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM