Pass a parameters to Click-once Setup.exe file - asp.net

I have a .net windows application, and i to run this application on client machine through asp.net web page.
I have used the Click-once technique which is publish the windows application in a setup package and place it as an IIS Application.
Now i want to pass a parameters to the windows application.
to pass parameters the click once app i am using a URL to .application and pass parameters as query string parameters file, but the problem here is the .application file doesn't setup the prerequisites first, i.e if the client machine doesn't have .NET framework installed the application will return error !!.
can anyone tell me how to pass a parameters to click-once application and check for prerequisites first.
also if there's another technique rather than click-once please tell me.

In the properties window of your windows application project, look for publish tab. You can set the prerequisites in this tab.
Here is also the detailed instructions from MSDN.

Related

Unable to connect to database with .NET Core 3.1 File System Publish to IIS

Question: How do I properly setup the database connection when using the File System method to publish an ASP .NET Core 3.1 Web-Api to IIS running on Windows 10? I believe I have added all of the correct Windows features for IIS because it runs and I am running VS 2019 Community in Admin mode.
This is my first time deploying a .NET Core 3.1 Web-API to IIS via the Publish method. I am able to successfully publish the web application to IIS. But it appears that something is wrong with the database configuration because when I try submit a login POST via Postman, I am getting an error message from the API error handling middleware that the credentials are invalid, which effectively means that the Web-API cannot connect to the database. As a test, when I try running in debug with IIS Express and change the connection string, I get the same error. Note: the IIS server logs do not contain any relevant output to confirm this, but I am pretty sure this is the problem.
In searching online, I am struggling to find a simple and direct walk through on how to publish a Web-API with a database connection. I suspect the problem is in the Connected Services section of the publish profile. I had to battle through some build errors that related to missing packages, and this item:
https://obscureproblemsandgotchas.com/development/c/dotnet-core-ef-migration-not-working/
Once I applied this change, the database data context strings could be read from the Publish Settings section of the publish profile, which reads the connection strings from the appsettings.json file. Though, I had to modify that string to remove an escape '' from the actual json value so that the test connection would succeed.
Any help is greatly appreciated.
You could set the connection string at the time of deploy from the visual studio as shown below :
Make sure you installed the .NET Core Hosting Bundle and .NET Core Runtime.
after doing all these things set the application pool identity to the administrator:
Open iis manager, select your application pool.
Click on advance setting from the action pane.
Under Process Model, click on the “Identity” value and select “Custom account”.
enter your domain user name and password which user has to access to the database and click ok to apply the changes.
after applying changes select the application pool and click on the “Recycle”.
restart your site.
Please refer below link for more detail:
https://forums.iis.net/post/2159167.aspx

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

can azure web role instantiate an activeX component?

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.

Reuse Windows Service classes

I have a ASP Net project of the type Windows Service.
When I build that project an exe file is generated.
Now I also have another project os the type Web Service, that uses classes from the previous Windows Service project.
When I build the Web Service, on it's bin/debug folder, the Windows Service exe is there, instead of a DLL.
This way, when I deploy the Web Service on ISS, I get an exception when the part of the code that instatiates a class on the Windows Service project is executed.
The only whay I found to solve this issue, is to make the output type of the Windows Service to DLL instead of EXE, and the Web Service runs correctly.
But, of course, when I try to install the Windows Service, I get this error:
Can I even do this?
Windows Services and web services are different project types. You cannot run the same executable. You have to options:
Either you put the common code into a class library and create a project for the windows service and one for the webservice
You create to build targets.
Option 1 seems to be easier for me

sharpdevelop, asp.net and run/debug it?

i created an asp.net project in sharpdevelop. i wanted to get started to see how debugging is and i am stuck already. How do i run the ASP.NET project? It just says its configured as a DLL. How do i launch it as a webpage. I see "start browser in url" but how do i get my code in a webpage or what do i use to do it? Also can i debug while doing so like i would in MSVS?
SharpDevelop does not have great ASP.NET support. It does not have a visual web forms designer, for example. If you need that I suggest you look at using Microsoft's Visual Web Developer Express Edition.
To be able to run, view and debug your ASP.NET web project with SharpDevelop you can use the Cassini personal web server. There is a closed source version of Cassini from UltiDev which I have not used. There is also an open source version of Cassini for .NET 3.5 which I have used. The open source version does need you to compile it from source however.
Once you have Cassini compiled you can do one of the following to debug your ASP.NET web project in SharpDevelop:
1) In the project options (Debug tab) choose Start External Program and then browse to the Cassini executable.
In the Command line arguments field specify the command line arguments for Cassini, for example:
d:\Projects\MyAspNetProject 8080 /
(The first parameter should be the folder containing your web.config and Default.aspx web page. The second parameter is the port number that Cassini will listen on. The third parameter is the virtual root to use.)
Save these project options and then when you select Debug | Run or press F5 you should be able to run and debug your ASP.NET project.
2) Alternatively you can start Cassini manually, with the command line arguments as described above, and leave it running in the background.
Then in the project options select Start Browser in URL and enter the URL for Cassini, for example:
http://localhost:8080/
Since SharpDevelop 4.2 there is support asp.net mvc3.
For debugging you can use either iis or iisexpress

Resources