-1

I've got a problem which I hope you can help me with.

I created ASP.NET 4.0 web application. I've also got .cpp file generated in some other app. This .cpp file contains functions, which always returns the same number of variables and which always takes the same number of parameters.

What I need to do is being able to use this functions in my web application.

But what is real problem is that I need to be able to replace this functions while running app. What I mean is administrator should be able to login, upload new cpp file, which will replace old functions with new ones. New ones will have the same names, parameters and result number, but will make calculations in a different way.

Is there any way this can be achieved?

Thanks for any help! MattheW

MattheW
  • 808
  • 11
  • 25

3 Answers3

2

Precompile the cpp code into dlls and let admin upload dll. Reference dll's from c# app using [DllImport("")] directive.

user1227804
  • 390
  • 1
  • 5
1

C++ will need to be compiled in some way or another. You can use a compiled dll written in C++ in your ASP.NET application but the code will still need to be compiled for ASP to be able to use it.

The compiled DLL can then be loaded and unloaded to accommodate changes to the function. You could perhaps even make the ASP.NET server compile the file somehow, but the code still needs to be compileable to a DLL to make it executable.

Dervall
  • 5,736
  • 3
  • 25
  • 48
1

You need to expose the C++ code via another dll.

The first choice is pinvoke. See:

How to set up a C++ function so that it can be used by p/invoke?

It's also covered here: http://msdn.microsoft.com/en-us/library/aa446538.aspx

Technically you could also expose via COM or write in managed C++ but those are both overkill if you're just trying to expose a few C++ functions.

Community
  • 1
  • 1
bryanmac
  • 38,941
  • 11
  • 91
  • 99