0

I use a third party DLL loaded to c:\Windows\System32\ in my local ASP.NET project. What kind of Microsoft Azure service I have to apply to migrate and run the web application in cloud?

VMai
  • 10,156
  • 9
  • 25
  • 34
Buratino
  • 11
  • 6
  • 1
    Why does it have to be located in the system folder? – sharptooth Aug 01 '14 at 06:39
  • Because I load it on OS startup. This library written in pure C and I refer to it's functions in unsafe mode. I'm not sure if it compatible with ASP.NET references. If you now how to connect С DLL to project please advice. – Buratino Aug 01 '14 at 06:46
  • So you use P/Invoke, don't you? Then it's not necessary to put the library to the system folder http://stackoverflow.com/a/2864714/57428 – sharptooth Aug 01 '14 at 06:49
  • That's P/Invoke. The linked to answer explains that you can tune it so that it can load the library from anywhere. – sharptooth Aug 01 '14 at 06:57
  • But what should I do on the cloud side? I know the library path on my local mashine, but don't know after uploading to the cloud as website (not VM). I have to drop dll folder to ASP.NET project root before uploading? – Buratino Aug 01 '14 at 07:46
  • You have to include it into the project and figure out how to locate it relative to the project root. For example, you can use `RdRoleRoot` environment variable in case of web role. – sharptooth Aug 01 '14 at 08:00
  • Am I do right? ```String rootPath = Environment.GetEnvironmentVariable("RoleRoot");``` ```SetDllDirectory(rootPath + @"\myFolderWithDll");``` – Buratino Aug 01 '14 at 09:00
  • Well, does it work? I guess not because your role contents ends up in `approot` subfolder. – sharptooth Aug 01 '14 at 09:19
  • Actually no. Look, I didn't get necessary path information here: http://trydll2.azurewebsites.net/Home/About – Buratino Aug 01 '14 at 10:03
  • Then what did you get? – sharptooth Aug 01 '14 at 10:09
  • Nothing. String vars are empty or null when I expect root path. – Buratino Aug 01 '14 at 10:12
  • Does `Environment.GetEnvironmentVariable("RdRoleRoot")` return an empty string on Azure? – sharptooth Aug 01 '14 at 10:16
  • Yeah, as I can see on the site that result of ```string roleRootDir = Environment.GetEnvironmentVariable("RdRoleRoot");``` is just ```roleRootDir =```, so empty output. – Buratino Aug 01 '14 at 10:22
  • The link you provided leads to "Azure website", not a web role. I have no idea if you can run unmanaged code in website. Anyway you could try listing all environment variables and perhaps find one which gives you the application root. – sharptooth Aug 01 '14 at 10:35
  • That's works: ```string roleRootDir = Environment.GetEnvironmentVariable("HOME"); var home = Path.Combine(roleRootDir, @"site\wwwroot\");``` – Buratino Aug 01 '14 at 11:49
  • Thank you, sharptooth for direct me! :-) – Buratino Aug 01 '14 at 12:04

1 Answers1

0

If you need to manually install this DLL in the above mentioned directory, best way to host your application would be in Azure Virtual Machines (IaaS). There you get full control of the VM and can install anything you like.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Could he use a web role and install the library using an elevated startup task? – sharptooth Aug 01 '14 at 06:50
  • He possibly could but there's an overhead of converting the application to run as web role (because of web role's stateless nature). IMHO the least painful migration path would be Virtual Machines. – Gaurav Mantri Aug 01 '14 at 06:55