1

I want to use a C++ library for my asp.net website. I don't know how to make a .dll of the library and make it work. I tried making a dll and import it to asp.net. Do I need a to do something in the c++ code for the dll to work?

Source code: http://warp.povusers.org/FunctionParser/fparser.html

  • what is not working? is your server 32 or 64 bit? there are some compilation options you need to set in the C++ project if it is a 64bit machine, and the C++ lib is a 32bit dll, you need to ensure that your application pool hosting the site is set to enable 32 bit application Read here to see how: https://help.webcontrolcenter.com/kb/a1114/how-to-enable-a-32-bit-application-pool-in-iis-7-dedicated-vps.aspx – Allanckw Sep 14 '17 at 15:07
  • 64. but i cannot find out how to make the dll from the source. i've made a dll before but i can't find out what to link to make it work – Pieter van der Mullen Sep 14 '17 at 15:10
  • can you check ur IIS application pool setting to see if it allow 32bit applications? – Allanckw Sep 14 '17 at 15:10
  • 1
    your problem is way too broad. Grab a compiler, feed it the source if there comes something out of it, use it, for example with this: https://stackoverflow.com/questions/772041/using-c-library-in-c-sharp but there are 30K of posts about roughly the same topic https://stackoverflow.com/search?q=use+c%2B%2B+dll+from+c%23 – rene Sep 14 '17 at 15:13
  • C++ is usually unmanaged code. So you need to find a compiler and compile the C++ .Net cannot comunicate with unmanaged c++ dll's like it does with other dotnet dlls. so the you must use the DotNet interop functionality to "wrap" the dll to be able to use it with dotnet. https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interop/ this is a big task. If this is all new to you, I would suggest to find a different library that is already wrapped, or find a managed dotnet library. with similar functionality. – Gerrie Pretorius Sep 14 '17 at 15:39
  • I've already searched trough stackoverflow for an answer but nothing helped. and stackoverflow.com/questions/772041/using-c-library-in-c-shar‌​p didn't either. and i run it for now in vs2017 so the server is not the problem it is that i can't make a dll without some sort of an error. – Pieter van der Mullen Sep 14 '17 at 15:41
  • Gerrie Pretorius i'll look into it thank you. – Pieter van der Mullen Sep 14 '17 at 15:43
  • _"i can't make a dll without some sort of an error"_ - telling us what the error is may give us a bit more of a clue. – PaulF Sep 14 '17 at 15:44

1 Answers1

1

You could use:

    [DllImport("dllname.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern double FunctionParser();
Aiko
  • 153
  • 2
  • 16