Click here to Skip to main content
15,901,426 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralMessage Closed Pin
10-Apr-17 1:18
johnwiliam10-Apr-17 1:18 
GeneralRe: Conversion of a windows project to Web Apllication Pin
Dave Kreskowiak10-Apr-17 2:38
mveDave Kreskowiak10-Apr-17 2:38 
AnswerRe: Conversion of a windows project to Web Apllication Pin
ZurdoDev4-Apr-17 1:57
professionalZurdoDev4-Apr-17 1:57 
Question[Solved]NFS for ASP.NET MVC 5 Pin
Member 1299209410-Mar-17 9:14
Member 1299209410-Mar-17 9:14 
AnswerRe: NFS for ASP.NET MVC 5 Pin
Eddy Vluggen10-Mar-17 12:20
professionalEddy Vluggen10-Mar-17 12:20 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Member 1299209410-Mar-17 21:20
Member 1299209410-Mar-17 21:20 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Eddy Vluggen11-Mar-17 6:47
professionalEddy Vluggen11-Mar-17 6:47 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Member 1299209411-Mar-17 7:09
Member 1299209411-Mar-17 7:09 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Eddy Vluggen11-Mar-17 7:18
professionalEddy Vluggen11-Mar-17 7:18 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Member 1299209411-Mar-17 7:26
Member 1299209411-Mar-17 7:26 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Eddy Vluggen11-Mar-17 7:34
professionalEddy Vluggen11-Mar-17 7:34 
GeneralRe: NFS for ASP.NET MVC 5 Pin
Member 130068963-Apr-17 7:21
Member 130068963-Apr-17 7:21 
QuestionFileInfo.LastWriteTime(-12) is fetching Files modified long time back Pin
indian1439-Mar-17 0:00
indian1439-Mar-17 0:00 
AnswerRe: FileInfo.LastWriteTime(-12) is fetching Files modified long time back Pin
Jochen Arndt9-Mar-17 0:28
professionalJochen Arndt9-Mar-17 0:28 
AnswerRe: FileInfo.LastWriteTime(-12) is fetching Files modified long time back Pin
Richard Deeming9-Mar-17 0:58
mveRichard Deeming9-Mar-17 0:58 
GeneralRe: FileInfo.LastWriteTime(-12) is fetching Files modified long time back Pin
indian1439-Mar-17 8:09
indian1439-Mar-17 8:09 
QuestionNeed to write an Outlook Email in which body contains information a Table format Pin
indian1435-Mar-17 12:17
indian1435-Mar-17 12:17 
AnswerRe: Need to write an Outlook Email in which body contains information a Table format Pin
Dave Kreskowiak5-Mar-17 14:45
mveDave Kreskowiak5-Mar-17 14:45 
AnswerRe: Need to write an Outlook Email in which body contains information a Table format Pin
Gerry Schmitz6-Mar-17 9:00
mveGerry Schmitz6-Mar-17 9:00 
GeneralRe: Need to write an Outlook Email in which body contains information a Table format Pin
indian1438-Mar-17 23:51
indian1438-Mar-17 23:51 
QuestionFaking AppDomain.CurrentDomain.BaseDirectory, is this way too bad? .net/c# Pin
User 110609793-Mar-17 6:08
User 110609793-Mar-17 6:08 
Dear experts

The task I need to solve
For a legacy C++ application -let's call it NativeW32App.exe- I need to use an third party SDK to control an USB device and this SDK is only available as a .net assembly.
The whole SDK consists of about 70 assemblies and one of them -let's call it ThridPartyNetSDK - represents the interface for me.

The approach I go is, I implement a proxy in .net which is COMVisible and can be easely consumed by the C++ application.
So far everything works fine as long as the whole bunch of SDK assemblies is available in the directory from where the NativeW32App.exe is startet. And this (all assemblies in the app's directory) I try to avoid because it is one of about 50 SDK (from different third parties) we need to support.

So my next step was/is
Separate the SDK assemblies and my COMVisible proxy in a separate directory and hook into assembly resolving...
C#
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(SDK_AssemblyResolve);
... where I load the assemblies from the separate directrory in my SDK_AssemblyResolve.

The problem
It seems, that the SDK itself is loading some DLLs dynamicaly relative to the AppDomain.CurrentDomain.BaseDirectory which is
my NativeW32App.exe's startup directory.

The dirty (?) solution
I'm faking AppDomain.CurrentDomain.BaseDirectory in my proxy assembly class ctor
C#
// Very (?) dirty way to fake  BaseDirectory
AppDomain.CurrentDomain.SetData("APPBASE", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

Now finally this works, but I have my doubts
a.) According to the MSDN documentation setting system values (and I assume "APPBASE" is one) should have no effect. But it works fine so far Confused | :confused:
b.) I assume this can have side effects and is not appropriate for production
c.) It seems that there are better way, e.g. creating the AppDomain by myself. But I have no idea how to manage this for a COM assembly consumer.

Is AppDomain.CurrentDomain.SetData dirty or not reliable for production?
Does anybody has a hint to solve it in a better way, maybe with seperate AppDomain or what else?

Thank you very much in advance for your comments.

modified 19-Jan-21 21:04pm.

AnswerRe: Faking AppDomain.CurrentDomain.BaseDirectory, is this way too bad? .net/c# Pin
Gerry Schmitz3-Mar-17 7:06
mveGerry Schmitz3-Mar-17 7:06 
GeneralRe: Faking AppDomain.CurrentDomain.BaseDirectory, is this way too bad? .net/c# Pin
User 110609793-Mar-17 7:09
User 110609793-Mar-17 7:09 
GeneralRe: Faking AppDomain.CurrentDomain.BaseDirectory, is this way too bad? .net/c# Pin
Gerry Schmitz3-Mar-17 8:59
mveGerry Schmitz3-Mar-17 8:59 
GeneralRe: Faking AppDomain.CurrentDomain.BaseDirectory, is this way too bad? .net/c# Pin
User 110609793-Mar-17 9:07
User 110609793-Mar-17 9:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.