Replace assembly in ASP.net application - c#

I am trying to (mostly to see if it can be done) replace a dll-file in a ASP.net application. And just to make things more interesting, the file I'm trying to replace, is the same file that will (to a certain degree at least) hold the logic of how to replace it.
I've been able to replace almost every file in the project, except for the dll-files that are running, and currently I'm a bit stuck.
First of all, this is not something that should be performed often, so scalability is not an issue (doesn't matter if it takes up to a minute or so). Secondly, I do not want to use a Windows Service.
The only way (I have yet to try, but will start experimenting with) to achieve this (without using a Windows Service) is to create an application that is launced by the ASP.net app. Then the ASP.net app shuts itself down (using something like HttpRuntime.UnloadAppDomain();), hopefully this will unlock the files. Then the application swaps out the dll-files. However I'm thinking that there must be some other possible way to achieve this.
So what I'm asking is basically for ideas on how to solve this problem, because I'm about to run out of mine.

Related

Console application with read only pure HTML UI

Story
I would like to make an application with two parts:
1. Console
Normal, bash-like CLI, implemented by me. That would be the way of communicating with the user, processing information, etc.
2. HTML
I would like to print HTML somewhere on the screen. It would be updated by the console.
Question
What should be the approach here? I'm not sure if a Windows Forms or WPF application is good here. IMO, that's too heavy. Ideally, a console application + some additional process would be used. But I've never heard of anything like that. Could you give me names of some frameworks / technologies where this would be possible?
Or maybe the other way - create this application but emulate console within it. I'm not sure if this is feasible...

Windows Runtime access file from JavaScript in WebView

I am using Three.js to try and implement a cross platform 3D model viewer. At the moment I have got it working and embedded in my XAML and C# application for Win 8.1 and Windows Phone 8.1 with a WebView. At the moment I am using C# code to load models (triangle meshes) from files on the device as well as a bundled file. The problem is that this means that I have to invoke a JavaScript function from C# for every triangle that I want to add and this makes the UI unresponsive for a while. I have tried to run the script async and to run the loader async but it does not really help because the all the JS function calls need to be handled by the Core Dispatcher otherwise I get an invalid thread access exception. In the beginning I did not realize this and thought it would be simpler and of higher performance to do loading in C#. I will now probably have to redo the loader in JS...
What I need to ask now is for some information as of how I should access the files from of JavaScript. I know Windows RT supports its file access API from JS but I am guessing this is more for entire JS applications because it does not seem to work from inside the WebView*. I would also prefer something more cross platform though as this also needs to work for Windows Desktop, iOS, Android and probably Mac and Linux too, so what would be my best option for this?
*I have tried the JS at http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker.aspx in my WP 8.1 application but no file selector appears. My the WebView does seem to freeze up though but I also don't get any exceptions or so popping up.
PS. I have a sort of feeling that it might come down to me having to copy files to a temp folder that JS can access. This would not be ideal as copying will waste time but if it's my only option then I will probably have to go for it. If this my only option I would appreciate some help with implementing it because JavaScript is really not my language and I'm only using it because of Three.JS...
As soon are you're using the WebView you end up in a situation where you need to post messages back and forward between your host app (the C# code, assuming you didn't rewrite it) and the website you're hosting in the WebView. The two basically function in isolation from each other.
Can you not load your geometry using the documentation of the Three.js format? It looks to be available here: https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4
That way you can proxy the entire geometry across vs. each individual triangle.

running an application inside ASP.NET

I've written an application in C# that I would now like to host within an ASP.NET website (MVC 2).
The application can become quite resource intensive so I would like to set up the system in such a way that each user downloads the application and runs it locally, but still within the web page that I provide.
My first idea to solve this problem was to host the program within a silverlight application. However, the app I want to host was not compiled for Silverlight, and I would like to use MySQL in it, which also appears to not be possible directly (ie without a web service in between).
The bottom line is that don't have experience with these things directly yet, and I need to research the way to make any solution possible. So I would really appreciate some input to put me in the right direction, and not have to implement 3 wrong options before finding the right one. I would also really like to avoid JavaScript if at all possible.
Thanks in advance.
Update
I probably should have specified to begin with what the application is exactly.
The application as I want to host it on the website is a simple chat program. It needs an input box and text output. The old windows forms application won't have to run in ASP, but I want to use the class library behind it, which is a chatbot engine. That engine is the part that can be rather resource intensive.
So you wrote a "rich client" application and you want to serve it as a web/silverlight application. This is not possible without changing the architecture of your app, as you probably guess, expecially because you have to interface a database. If rewriting the application to support such architecture is not an option, the best in order to me is to use Remote Desktop, but you have to pay for licenses in order to support many connections.
If your application is not a web application then it will not run on the server. The only thing your server does is to provide a download location. For that, you wouldn't need a MVC site - static pages could fit. The programming model between normal applications running on the client and server applications running on IIS is completely different. So in short: you won't be able to host your client application in ASP.NET MVC. If this is a requirement you will end up rewriting the application.
If your application is ASP.NET WebForms and it becomes too resource hungry, then you probably won't solve it by just switching to MVC. You have different options then: more resources on the server side, analyzing what could be done to lower the resources required or moving away from a server based application. This is not a black/white decision, maybe a combination might fit.

Create a WPF "control" that is run in an external process

I have a WPF app which contains a number of child controls.
One of these controls hosts a third party library which underneath the covers runs some native code which throws access violations and crashes the application. Unfortunately removing the library is not an option.
What I'd like to do is spin up a new windows process, host the third party library inside that, and somehow communicate with it. Much in the same way that Google Chrome and IE8 handle browser plugins.
The issue is that the third party library needs to draw to the screen, so I have to somehow have the equivalent of an HTML iframe inside my WPF app's main window.
I'm not sure how to get started on this, it's proving difficult to google for thus far. Any advice is greatly appreciated.
This is a tough one, but fortunately for you there is a little work being done in this space lately.
Have you heard of the System.Addin namespace in .NET 3.5? It could probably help in this case. It allows for controls to be loaded in a separate AppDomain, but be displayed in the same UI. I'd imagine you'd have to do a little bit of work to get everything communicating properly (never done this before), but it's possible.
Have a look at this early post from the Add-in team: http://blogs.msdn.com/clraddins/archive/2007/08/06/appdomain-isolated-wpf-add-ins-jesse-kaplan.aspx
Seems like they keep their samples and helper code on codeplex: http://clraddins.codeplex.com/
I'm very interested in this, so if you get this working, let us know how this went for you!
Coming in way late. If you still need this, have you seen this project: https://learn.microsoft.com/en-us/archive/blogs/changov/hosting-wpf-ui-cross-thread-and-cross-process
I'm running multiple plugins in multiple external processes in my LOB app. My framework grew out of the project above.
Probably not the easiest of tasks. Have you considered hosting your 3rd party stuff in a separate App-Domain? That way you will also get a good level of isolation while saving you the hassle of another project. Does it have to be refreshed constantly or could you refresh at predefined points in your application? Maybe some scheme where you basically do a screenshot of the 3rd party output and show it as image in your original app would then be possible...

Can an exe compiled from C# be integrated into a website?

I'm a beginner in programming. I've just made a program called "Guessing Game". And it seems to work fine. Can I integrate it into a website? The CMS that I'm using is Mambo.
===
additional info's
Thanks for all your suggestions.
I still don't have any background about Silverlight, WPF and Java Script which I think sounds good. I'm using Windows and I programmed my "Guessing Game" from Microsoft Visual Studio 2008 and it's using Window application forms.
Yes I guess, for the moment I let it be and start to learn Silverlight or Java Script so that I can integrate it on my website:-)
Thanks for all your input guys:-)
Cheers
A standalone executable cannot be directly integrated into a website. You have a few choices though:
Allow your users to download the executable and run it locally for themselves
Rewrite your program in JavaScript to have it run directly inside of an HTML page, though this could obviously involve a fair amount of reworking
Use Microsoft's Silverlight technology, which allows you to code in C# and produce a web-based frontend similar to Adobe Flash. Your program logic should remain the same and you should only have to change the UI code. In fact if you're already using WPF for the front end, the transition will be even easier.
There are several questions that you still need to answer.
What is your server running? If its not Windows, your exe will not run at all unless it is compatible with Mono or a similar framework for your server's operating system.
How does your "Guessing game" interact with the user? If it is through a WinForms GUI, it will you will not be able to use that GUI on the web. If your game is a WPF application your easiest route may be to port it to Silverlight and serve it up on a web page.
It is typically not trivial to make a regular windows application run in a web environment since on on the web you are really running in the browser, not on Windows.
Yes - in general, when you're talking about software, anything is possible. The question is, how difficult will it be?
To understand that, you have to give us more details about "Guessing Game" including how it is designed, what it's interfaces are, how readily extensible it is, and how prepared you are to change or extend it.
For example, if it is a Windows Forms GUI app, then it will be diifficult to integrate into a web app. If it is a console app, then it will be a little easier. If you can modify it to run as a Windows Service, then a little easier. If you can modify it to accept input from the network (as opposed to getting input solely from the keyboard + mouse), still easier.
You may be able to use reflection to load your assembly into the web application, but most likely, the answer is no.
Your best solution is probably to re-write the game in javascript.
The short answer to your question is now. I'm presuming that since you're running Mambo you're web environment is a LAMP stack. However, you're "Guessing Game" is most likely a Windows application from the sound of it. For a beginner in programming, there is no integration path you're going to be able to take that will allow you to have your game running on your website.
However, here are avenues you can take, which will require a significant amount of time to learn. I'm not saying you shouldn't take time to learn, by all means you should! I'm simply trying to illustrate the fact that this is not something that is going to be doable in a couple of hours.
Silverlight - allows you to run C# code with a WPF like interface on your client's browser and can integrate with your web site through javascript.
Let your client download it from your website and run it off of their PC. This would actually be fairly trivial and would be your quickest option, but it sounds like it's not the kind of integration you were looking for.

Categories