Restrictions Calling DLLs Across Technologies?

I want to call a DLL in my programming language of ‘choice’. The documentation surrounding this clearly states that it must be a 32-bit DLL written in C, C++ or Delphi. But I wanted to call a DLL written in C#. It goes on to mention that the default calling mode is cdecl.

So my question is: why would this be the case? Is there any way to make it think a C# DLL was written in C, C++ or Delphi?

2

That very problem is what COM was designed to address. I’ll leave it to my good friend Jeremiah Morrill to explain what the problem is:

I explained briefly how simple exporting regular “C” methods can be to
share code between DLLs and the application. I also explained how C++
classes get flattened and compiled down and also how they are seen to
your CPU (more or less). If C++ classes just get compiled to static
“C” methods, which can be exported from our DLL, is that not
sufficient to reuse and share classes across DLLs? Yes…but not
without some major caveats as this would come at a cost.

  • The first disadvantage of exporting a C++ class is you must use the same C runtime in all DLLs/exe involved. So if one DLL used MSVCRT7,
    the caller of the DLL must be using MSVCRT7. The reason is different
    versions of C runtimes manage the heap differently, so if DLL A tried
    to free resources allocated by DLL B, memory corruption can occur.

  • The second disadvantage is the same compiler version must be used. This is because different compilers mangle names differently. Name
    mangling differences among compilers ensures a DLL built with
    Microsoft would have completely different symbol names than a DLL
    built with GCC. So when linking of your code occurs, the linker might
    be looking for “??4MyWidget…” when the export is really
    “MyWidget__Fi…”

  • Third, if a large change of the base classes in DLL A are made, even without breaking API, then DLL B that uses the base classes must
    be recompiled.

  • Forth [sic], if you take the last three disadvantages into consideration, we have a very tight coupling between our DLLs. This
    inhibits reusability of the module.

Sometimes these issues are not an issue for a given project. This is
usually acceptable when the project is small, or an in house utility.
That’s totally fine. But let’s pretend Microsoft ignored these
problems. All developers would have to use the same compiler version.
Applications would have to be written for very specific versions of
Windows. This would be a complete nightmare for everyone.

Looking at those problems, COM is a simple solution for solving them. By exposing your C# dll to COM, you can call it from any other COM compliant language.

1

Your language of choice supports calling any native DLLs written in any language. It’s not really limited to those made with C, C++ or Delphi. You could call Fortran DLLs too, for example.

The problem is that the C# DLL is a managed DLL. That’s a completely different beast from a native DLL. You will need to put a bridging layer in between the C# and your code. Robert Giesecke’s Unmanaged Exports is one simple way to do that.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật