|
=========
|Foo|Bar|
|Foo|Bar|
=========
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Yes Implemented thank you very much buddies
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
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...
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
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
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.
|
|
|
|
|
Apparently, you could have accomplished the same thing by accessing AppDomainSetup.ApplicationBase.
And since it has both a setter and a getter ... You just took a different route.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
No, that does not work. AppDomainSetup is only relevant in case you create a new app domain.
Anyway, thank you for your comment and a .
modified 19-Jan-21 21:04pm.
|
|
|
|
|
|
Looks promising, thank you for this. I will dive into it and another
Bruno
[Edit]
Just checked the link. That is what I'm currently doing. But the problem remains, that some of these assemblies (resolved by ResolveEventHandler) do dynamically load by themselve assemblies with the assumption that these assemblies are located in AppDomain.CurrentDomain.BaseDirectory .
modified 19-Jan-21 21:04pm.
|
|
|
|
|
what should be present using modules and visual basic version?
|
|
|
|
|
That is not a good question for several reasons. First, your subject line - this is a C# forum so it's not necessary to put that in the title. What would be useful, instead, is a meaningful description of the problem. Second, your question is unclear. Try to explain in more detail what it is that you wish to know.
This space for rent
|
|
|
|
|
Looking at his profile, I suspect this is a spammer-in-waiting.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I rather think you're right.
This space for rent
|
|
|
|
|
Anyone understand this question ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Nope, and I've got a ton of VB/VB.NET experience.
|
|
|
|
|
Are you sure all this reply is for me ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Well, you did ask if anyone understood the question.
|
|
|
|
|
I understood.
I have mistaken your signature with your answer.
Note: first link don't work.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Well, it used to work. I guess Chris and Company removed the post...
|
|
|
|
|
|
No but I replace the link I had with yours if you want.
|
|
|
|
|
No need.
This space for rent
|
|
|
|
|
i want the code of ask question answer in asp.net and c#
for my asp.net project
|
|
|
|
|
|
And I want money.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
ppolymorphe wrote: We do not do your HomeWork.HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will help your teacher spot your weaknesses and set remedial actions.So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help. Substitute "work" for "homework." Homework or work work, we don't do everything for anyone. But for some reason, the moment people see homework they immediately start bashing the user (not saying you did that.) Of course we'll help with homework, and gladly, as long as they can ask a proper question.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
1. We won't do your work for you.
2. There are so many different ways to do it. Just get started and then when you get stuck, ask a specific question and we'll gladly help.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|