can azure web role instantiate an activeX component? - asp.net

I have an asp.net website that I'm looking to migrate over to Azure. I have been doing some analysis of the website and code to understand issues with the migration. I am confident that 95% of the code will be fine as most of it is pretty standard web forms and dot net programming.
However, I have just run across an ActiveX component that is installed into the \windows directory on the webserver.
I am wondering if this will be an issue for the migration? There could easily be a number of follow-on questions as well depending on the answer. How do Azure web roles handle instantiation of activeX server components? Can I include the DSINTX.OCX file into the solution or do I wrap it in a dotnet assembly?
private DSINTXLib.Dsintx m_dsintx;
...
m_dsintx = new DSINTXLib.DsintxClass();

Installation of the ActiveX component should not be difficult. You can use a startup task running elevated to install it, assuming that there's an unattended installation mode for it. I blogged about this process for a Windows Service a while back.
http://blogs.msdn.com/b/golive/archive/2011/02/11/installing-a-windows-service-in-a-worker-role.aspx
If you don't have an installation file, then create a script that installs and registers the control and then use RDP to your role instance to debug. The blog post goes over some of these techniques as well. (Use notepad to create the command file, not VS.) You can add the OCX to your project, but be sure to set the Copy Local property to True so it becomes part of the package that is sent to Azure.

Related

How to deploy a Web Service from Xamarin Studio

Good afternoon, everyone.
I'm running Xamarin Studio (Mac OS) and I need to deploy a Web Service in order to build a safe communication with a MySql Database which my Xamarin.Forms app depends on
So far I've opened a new solution and added a new "Web Service with CodeBehind" from the ASP.NET Web Forms palette.
Now I have all template stuff: a DataWebService.asmx with a single line and a DataWebService.asmx.cs with an empty class inheriting from System.Web.Services.WebService.
Now, all I want is to learn how to deploy this Web Service so it can be imported by my other App and consumed.
(I do have a domain to deploy it to, but I won't mind localhost)
In order to make things as simple as possible, a HelloWorld application will do just fine.
----- Extra comments:
I suppose this is pretty much everything I'd have to do in Visual Studio, but I'm avoiding the need of another machine - even a virtual one, once I don't have a Windows license.
It seems to me that a wizard should be able to do the rest, but apparently there isn't such a thing in Xamarin Studio (which I'm hoping to be wrong)
The CodeBehindService.asmx.cs lacks the [WebService] directive I've seen on my research so far, which makes me think Xamarin Studio is still incomplete and can't support me in this task
I don't mind doing some work myself, though I'm not sure of what would be needed. My priority is: deploy
What I have: an almost empty asmx file; a dll binary
What do I do with it?
I tried simply uploading them but the "Add Web Reference" wizard asked for a discovery file; as you can see I lack the basics.

Complete Web Deploy Package -> Web Application and Data Project

The product I’m trying to create a package out of is a Web Application and a Database Project. This Package needs to be deployed to multiple IIS Web Sites which individually has their own application pool and bindings. In the end I would want the package to be built by a TFS Build Server into a .zip file which via msdeploy.exe somehow can be deployed to these web sites by settings the web site, application pool, binding and destination database in deploy time. It should create if items does not exists and update if they do.
I’ve been researching quite a lot on Web Deploy 3.0. Most of the stuff I find on the internet via google is about defining the package and publishing from within Visual Studio which is not exactly what I want because I want to be able to have control over the settings at deploy time.
So far I can create a package relatively simple via the Publish dialog in Visual Studio 2013. I can even add my SSDT project dacpac file to the package using the “Update Database” checkbox in the Publish window. But I think a lot of things happen behind the covers which doesn’t seem logic how to do manually.
Ultimately the questions I have right now which I hope someone can help me with is:
How do I define dbdacfx settings in deploy time when deploying a
package? (Ie. Target sql server, database, username and password.) Or
can I parametrize these settings somehow into a parameter.xml file?
Can I use the publish profile xml file from my SSDT project?
How do I make my package create a new web site if it does not exists?
I can only find information about creating applications under already
existing sites.
When and if I create a web site via the package, how do I define the
associated application pool? Like creating it if it doesn’t exist or
update it if the target framework is incorrect?
I’ve read about providers. For instance appPoolConfig provider but
how to utilize this at deploy time isn’t very clear to me – can
anyone elaborate or perhaps point to a source explaining it?
Is there any good books covering this area or perhaps even a better
alternative?

Why would installation method affect .NET service?

I have built a WCF service that is hosted in a Windows Service following this article: http://msdn.microsoft.com/en-us/library/ms733069.aspx. Part of what the code in the service does is join a multicast group and listen for data that is broadcast to the group. Then it processes it. I have found that when I install the service manually using InstallUtil it works fine. To install it manually I do the following:
Build the MyService project in Visual Studio.
Right click on the Visual Studio Command Prompt and choose Run As Administrator
Navigate to the folder that has the MyService.exe file
Run the InstallUtil command as follows: installutil.exe MyService.exe
The service installs in Windows fine and then I start it. Then I run my ASP.NET application which is the client for the service and it runs fine. The service receives and processes the data just fine.
However I am trying to use Advanced Installer to build an MSI or EXE that will install the service and the ASP.NET application all at once so it doesn't have to be done manually. I am able to successfully create the Advanced Installer project that does this and it actually installs both the ASP.NET application and the Windows Service just fine and it starts my Windows Service too. However the really strange thing is that when I run the application I find that my service code can not receive any multicast data. It seems to block on that line of code and I never get any data. Does anyone know why this would happen? I have tried using an EXE and using "Run As Administrator" when I do the Advanced Installer installation. Here is the code from my service.
_groupAddress = IPAddress.Parse(_myIPAddress);
_listener = new UdpClient(_myPort);
_groupEP = new IPEndPoint(_groupAddress, _myPort);
_listener.JoinMulticastGroup(_groupAddress);
byte[] _bytes = _listener.Receive(ref _groupEP);
It seems to block on that last line of code and it never receives any data. This only happens when I install using Advanced Installer. When I install manually it works fine.
A service is configured to run under the identity of a user. Is this different when you install with the different methods?
Do you use the same port number in both cases, if not it could be the firewall.
99% sure that you have checked it, but check that the service is running after it is installed using advanced installer.
Check the event log for problems with the service.
It may be that your Windows Service is not running with sufficient credentials to perform this action. To test this, I'd recommend trying to change the user account being used for the service to see if that makes any difference.
To do this, go to the services applet (start, run, type services.msc). Find your service, right-click, properties, "Log On" tab, choose "This Account" and select an administrator user account that the service can run under.
I initially thought as the guys said this was a problem with the user credentials. But since you said in both cases the service is installed under the LocalSystem the problem seems to be elsewhere.
I recommend you first check the system "Events Viewer" for any messages regarding your message failing to start, maybe there you can find more information about the failure case.
If you can't find more detailed there I suggest a little bit of reverse engineering, to see what InstallUtil does and Advanced Installer doesn't, or the other way around. Advanced Installer comes along with the Repackager tool. You can use this tool to capture the system changes performed when running "InstallUtil" by providing a dummy executable to the Repackager when it is asking for the setup package, for example Notepad.
When the Repackager launches Notepad, leave it open and run your install command for the service, after the service finished installing, close Notepad and leave the repackager do its job. Then analyze the new project that it generates to see what resources has captured, like files, registry, services, etc...
You can also capture the install package create by Advanced Installer to see if the services installation from it creates less or more registration info for your service.

How to call a windows form app from ASP.net

I am trying to use activeX to start a windows form application written in C# from my ASP.net website. When I click a button I would like a new page to open up and activeX on that page would call my windows application.
I am using Visual Studio 2010. I have followed this tutorial: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx
However, that tutorial is only for 1 C# file which you compile via console.
My questions are the following:
1.How would I compile the entire windows form project to use the /t:library and regasm?
2.I have followed this question answer to modify my windows form application: How do I create an ActiveX control (COM) in C#?. However, like in both examples, they do not have a Main method. When I tried to modify the code of my windows form app, I get the error saying the program does not have a Main method for entry if I take it out and replace it with a Launch() method. I am sure I am missing something?
3.Would I just write the java script on the new .aspx page to access the application?
P.S. I am trying to open this open source windows form application: http://www.codeproject.com/Articles/239849/Multiple-face-detection-and-recognition-in-real-ti
Thank you kindly
You can not do that. It would be huge security risk to allow websites to execute arbitrary code on local machine, outside of some sandboxed environment (like JavaScript for example).
AFAIK closest thing to what you want is ClickOnce, that is a installer and use it to install your WinForms app on client machine. It's easy to make installation for project, just right click in VS and publish.
There is a solution that you may be able to use called ClickOnce.
http://msdn.microsoft.com/en-us/library/t71a733d%28v=vs.100%29.aspx
I've created enterprise applications that I deploy to an internet accessible location and link my users to the "publish" website that allows them to click, install, and run the application.
Keep in mind that this will install the application in addition to running it, so if part of your requirements is to not install it, then ClickOnce won't work for your scenario.
I would suggest you can create ActiveX control instead of a Windows Form. You can create it using legacy VB (VB 6.0). You can refer something like
http://www.visualbasicbooks.com/activeXtutorial.html
http://blogs.msdn.com/b/ajma/archive/2004/08/12/213868.aspx

Newbie Trying To Deploy Asp.Net Website

I'm basically wondering what the best way to deploy an Asp.Net Web Site is, mostly from the point of view of security. Right now, I'm trying to publish the website using Visual Studio 2010. Could someone direct me to a good tutorial on how to do this securely? For example, can it be done over an encrypted connection via Visual Studio? Is it necessary to install any software on the server to do this? Should I use a different program to open up an SSL (TLS) connection first, and if so, which program (does it come standard with windows)?
The server is running Windows Server 2008. Development is on Vista.
Many thanks in advance for any direction in this matter!
Andrew
I would publish the site to your local machine and file copy the files across to your test/production environment. As a rule we don't publish sites straight from VS to test or production.
For example you don't want to accidentally push things straight from dev into a live environment do you?
As far as the file transfer security goes you could use SFTP.
Note: First thing is to check with the owner of the server, as they often will provide you an FTP connection and will take care of configuring IIS.
If you want to add security, make a keyfile and sign your assemblies and consider running Dotfuscator on your dlls, the community edition is included in Visual Studio. Here is an earlier question where I've put more info on Dotfuscator.
If you have to do the deployment yourself, here's a few things to consider.
XCopy (easy)
MSI (have to create a setup program, you can do this easily in Visual Studio)
There is no security advantage in deploying using Visual Studio, but you can use Visual Studio to create a small setup program. One thing you want to make sure for security is DO NOT deploy any .cs files. Prepare your files, you should compile in Release mode, make sure debug is not enabled in your config file, keep your bin and it's dll, also the aspx, asmx, ascx, svc, css, js, and config files.
XCopy: Install a small FTP server, or use one your company alreayd has, this will allow you to get your files once you are logged into the target machine. You should be able to get an administrator account for the target machine, just ask the sysadmin of the domain, then log on using remote desktop, got to your ftp site, and download your files. Open IIS on the target machine, create a virtual directory and a pool. Copy your files to the location, configure your connection string to your DB if you use one, then test your website.
MSI: same process as above, except the setup will create the virtual directory and pool for you.
Here is extra info on best practices from the official ASP.Net website.
If you have some control on the server (e.g. to configure IIS7), you might want to look into Microsoft Web Deploy (new product just been released):
http://weblogs.asp.net/scottgu/archive/2010/09/13/automating-deployment-with-microsoft-web-deploy.aspx
Haven't tried it myself, but looks quite slick and it apparently encrypts the data being copied up, so might suit you.

Resources