Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

What's the best way to dynamically load UWS.Configuration.dll ?
newahkow
#1 Posted : Tuesday, February 28, 2012 4:51:38 AM(UTC)
Groups: Member
Joined: 10/11/2011(UTC)
Posts: 19

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Hi, my application loads UWS.Configuration.dll when required so that user can change port.
I don't add reference to the DLL in the project so that the application still works if UWS is uninstalled.

I have came up with the following code to load the DLL.
Code:

string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + Path.DirectorySeparatorChar + "UltiDev" + Path.DirectorySeparatorChar + "Web Server" + Path.DirectorySeparatorChar + "UWS.Configuration.dll";

Assembly UWSAssembly = Assembly.LoadFrom(path);

I wonder if it's ok to get the path this way. Or maybe there is a better way?

Thanks!
Ultidev Team
#3 Posted : Tuesday, February 28, 2012 9:53:27 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there!

Although your path calculation is correct (it could be more efficient if Path.Combine() method is used), UWS.Configuration assembly location, other than GAC, is not documented or guaranteed. You could still, probably, use Assembly.Load(string asmName) method to try to load UWS.Configuration from GAC instead of file system.

Can we ask what is the use case for changing UWS configuration while UWS is not even installed?

Also, we'd like to mention that UWS build 15 that will be released later today or tomorrow, will have UWS uninstallation moved from "Programs & Features" to UWS Programs menu folder. This allowed us to show a warning when UWS is uninstalled while there are registered applications (see screenshot).

Best regards,
UltiDev Team.


Ultidev Team attached the following image(s):
Ultidev Team attached the following image(s): UWS Uninstall Confirmation screen.png
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
newahkow
#4 Posted : Wednesday, February 29, 2012 2:18:07 AM(UTC)
Groups: Member
Joined: 10/11/2011(UTC)
Posts: 19

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Thanks, Assembly.Load() needs a fully qualified name with specific version number. I think it is not suitable. Assembly.LoadWithPartialName() is obsolete.

The application should work with or without UWS installed. Even if the user have installed it, she may uninstall it later. The worst case is when UWS could not be installed at all (sometimes I have error 2869 when installing UWS).

Ultidev Team
#5 Posted : Wednesday, February 29, 2012 9:33:58 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there!

Using Assembly.Load() should still work even if you specify version-specific full name, because with every new version of UWS.Configuration.dll we register it in GAC along with binding redirection manifest, so that programs using UWS Configuration API would always get its current version regardless which version they were trying to load - just like .NET Framework service packs do. This enables users to upgrade to newer versions of UWS without breaking applications that use UWS Configuration API.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
1 user thanked Ultidev Team for this useful post.
newahkow on 2/29/2012(UTC)
newahkow
#6 Posted : Wednesday, February 29, 2012 8:43:24 PM(UTC)
Groups: Member
Joined: 10/11/2011(UTC)
Posts: 19

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Thanks, I just installed build 15 and the following really loads this new build:
Code:

Assembly.Load("UWS.Configuration, Version=1.0.0.14, Culture=neutral, PublicKeyToken=cc16caed94880aaa, processorArchitecture=MSIL");
Ultidev Team
#7 Posted : Wednesday, February 29, 2012 9:44:57 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Great! We are happy it worked.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.