Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Make a C# wrapper for a managed assembly

Posted on 2013-01-20
4
Medium Priority
?
352 Views
Last Modified: 2013-01-24
Before I begin, let me start my saying, I understand what I am asking for is very unusual
and not normally required.

I have a serial of assemblies, six in total.  The are true .Net assemblies. They are actually the Red-gate SQL Compare SDK  assemblies.

I have a license to use these, however, the license only allows me to build against them on one machine.  I actually have three computers which I use on a regular basis, and more than once have needed to recompile my app to fix a bug on a machine that does not have the license installed.

My solution to this, is, I wish to make a wrapper dll, that will allow me to have all the functionality of the original dlls.  I could then build this against the correct licence then use this dll as is, on all my computers, with the need to recompile it.

The Red-gate website actually suggest this as an option to prevent constant re-licensing.

My question is, as these assemblies have many classes, methods, enums, etc. is there a simple way to make this wrapper, without having to manually map every class, method, function, enum etc.

I know with COM+ I can use the .Net import tools, but I have never seen a tool to import a .Net assembly.

Any and all help is greatly appreciated.
0
Comment
Question by:townsma
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Orcbighter
ID: 38800801
To simplify your problem:
You have a PC AAA on which is installed the Red-gate licence.
You have software that runs on three machines: AAA, BBB, and CCC
There is a bug in your software on BBB and you would like to rebuild your app on BBB.
1. Are you unable to replicate the bug on AAA, do the code-fix and then rebuild and then reship the software to BBB?

To proceed with your request implies that you will make a fix on BBB and rebuild on BBB, allowing the software on BBB to diverge from that on AAA and CCC. Is this correct?
0
 
LVL 6

Author Comment

by:townsma
ID: 38800885
The purpose of the different machines is simple, I have a desktop in my office, I have a desktop at home and I have a laptop for when travelling.  All computers have VS2010 installed, along with the source code of my app.  But only the system at the office has the redgate sdk tools installed.  The other two computers have the redgate runtime files only.

If I need to do an urgent hot fix I may be at home, or I may be on a different customers site.  Either way I need to build the app again.  Because the redgate sdk is only on the office system, the build will fail.

So RedGates solution is to make a dll, that acts as a wrapper to their assemblies, this will be compiled on the office system, and the license will be embedded in the dll.  This built dll, along with it's dependent files, can then be copied to any other computer, and used in my app.

As the dll itself will not be rebuilding, the build of my app will succeed.

I hope this explains it better.

Thanks
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1500 total points
ID: 38801343
I'm not sure if there's any other way to do what you seek outside of wrapping every method you want to use from the API. The only other thing I can think to do would be to use Reflection, and there would be a performance penalty for that. You would have to judge whether or not this penalty was acceptable for your application.
0
 
LVL 9

Expert Comment

by:Orcbighter
ID: 38808743
I agree, there seems no way to avoid making your own DLL with stubs for the APIs.
One good point is that the your dll only has to provide wrappers for those parts of the API that you actually used, not the entire Red-gate API.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question