Production application referencing development directories - asp.net

I am building a web application with .NET 3.5. I have several class library projects being referenced by my web forms.
I am deploying using a web setup installer.
When I install the application and hit the opening page, I get null pointer exceptions to some (not all) of the objects in my class library. Looking at the stack trace reveals that something somewhere is looking for a directory that exists only on my development machine.
When I do IISRESET, the errors vanish.
Does anyone have any idea why my application (web.config is compiled with debug="false") is attempting to look for things on my local dev machine?
My active build is set to release.
Thanks.

Did all the .dll's you used in your site get published with your code? If not make sure they are placed in by the installer, and the web config is not hard coded to look for references.

Open Visual Studio, look at the References folder and check to see if any of those references are pointing to the file(s) in your DEV machine. If so, I suggest you add a new folder to your app (i.e. Assemblies) and add all the dlls your application references in that folder.
After that, make sure all the references in your project are pointing to the dlls in the Assemblies folder and not some folder that only exists in your DEV machine.

Related

ASP.NET failing to call a dll

My question may have already been asked but any of the answers match my case.
I need to do a website (ASP.NET MVC 4) with some features of a software. I have finished to developed my website and wanted to test it in a test environment (Windows server 2008 - 64bits).
It works perfectly fine with my dev computer(windows 7 - 64bits). But after I deployed it on IIS, one of my features doesn't work.
This feature is a bit particular. It need a 32 bits COM written in VB6 (this dll can't be change) that call an other dll. When I test the website deployed on IIS, the first ddl is called fine but the 2nd seemed to be not called at all.
This dll are in the installed file of the software. I have the same version of on both computer.
I authorize my app pool to use 32bits application. I tried to give some access to my dll (the COM and interop) like IUSR, IIS_IUSRS. But nothing seems to work.
I have checked both of my dll are registered properly.
I'm a bit lost. Can someone help me ?
PS: Sorry for my English, I can speak but I'm really weak with syntax.
Some suggestion here:
You need to figure out which managed dll, native dll and lib files are referenced by your application (directly or indirectly).
For managed dll, make sure they are in the web's bin folder.
For native dll and .lib files, check out whether those .dll and .lib files are in the PATH. If not, you can either copy them to there; or, you can put them into a folder and add that folder into the PATH. Then restart VS and IIS (command "iisreset") to make sure the setting is picked up.
By the way, putting all of the files in the web's bin folder won't help. The reason is CLR copies the files into a temporary folder under framework directory and run the web there, but CLR only copies away managed dll (not the native ones), so you still get "module not found" error.
I have reproduced this error using the following sample solution
Web1 references a managed c++ project say "MCpp1.dll". The project further references two unmanaged c++ projects with the output say "Lib1.lib" and "Lib2.lib"
If I copy all of those files into web's bin folder, I get the exception of "module not found error".
I create a folder say "C:\Lib" and copy "Lib1.lib" and "Lib2.lib" into it and add this folder into PATH. I restart VS, and also run "IISReset" since I have a IIS web
Open VS and request a page and it works now
I have also contacted the CLR/Fusion team for suggestion of how to get the related module name when this exception happens, which should be very helpful to make diagnosis.
Hope this helps ,
GODFATHER

How to re-build deployed ASP.net website?

I'm connected to a customer's site. There is a bug in an ASP.net MVC site i'm trying to solve.
As i make changes in the various .cs files, the web-server is not changing it's behavior. It seems that the web-site is determined to use the pre-compiled .dll files in the Bin folder.
How can i instruct IIS to recompile the web-site from scratch, in order to pick up the live changes?
I tried deleting my own .dll file:
\Bin\Contoso.dll
But then the web-site crashes.
Note: i am asking how to do this without access to Visual Studio; otherwise i would have changed the web-application into a web-site and redeployed.
You will need to recompile the dll with your changes from your development machine and deploy them. MVC ( I mean asp.net application) uses dll not source code. In short , what you are asking is not possible.

How to create and run an ASP.NET website in an installed application's bin directory

Our application is composed of mixed C# / managed C++ CLI / native C++ assemblies & DLLs.
We have a wrapper assembly that exposes the application's API.
FOR EXAMPLE...to create new console applications that use the API, you must reference that assembly, and also set the console application's output directory to the BIN directory of our installed application. ( due to the use of reflection, etc., everything must stay in the app's BIN directory and output to that directory, you cannot do a copy local of just the one assembly or nothing works )
My issue is when creating an ASP.NET web forms application (nothing to do with the console app), I would like to use that assembly, so I need the web application to "live" in our application's BIN directory.
When I try that errors occur due to ASP.NET trying to preload every single assembly in that BIN directory.
Can someone provide instructions on how to get this to work? I've spent hours now on every combination of referencing assemblies, copying them all, and trying to use LoadFrom.
Without seeing the construction of this it's hard but ...
Bin referencing
Create a web application and reference the necessary dll from the web site via bin references
Right click the web application, select the browse option and pcik the dlls you need to reference. Select copy local to true so you get the dll copied through to the web application so you aren't forever dependent on the console app being exactly where it needs to be in relation to the web app.
Not a solution I would necessarily go with though - it seems like the arcitecture of the system is a little off. Cross you have to bare etc...
OR
GAC referencing
the dlls that you need to reference from the console app - strongly name them and put them in the GAC (global assembly cache). Both apps will be able to see them then.
Copy over the dll
I guess there is another solution around adding a post build step to the console app that reruns a batch file that will copy over the dlls into the web app. I think that's going to be pretty much the same as the bin reference though really.
Probing element
You could use a <probing> element in your web.config to instruct the CLR to search for other directories for assembles (it normally just does the GAC and bin (a simplification to be fair is that) ). This is going to enable you to reference your API folder - but only if it is under your application path. Although someone here has used an NFTS junction to get around this.
More info here
In fact this answer gives a lot more detail about this kind of thing
How do I reference assemblies outside the bin folder in an ASP.net application?
And good luck

How do I host my Mvc web app using plesk panel?

I have registerd my own domain name and web hosting space too on parallels
thay are having there plesk control panel.
I know that for html pages I need to copy my all pages into httpdoc folder
But what about by MVC WEBSITE?
HOW DO I HOST IT?
CAN ANYONE HELP ME?
To expand on the previous answers;
You need to ensure you are copying your websites 'bin' folder.
You may also need to ensure that the MVC assemblies are in it.
When you installed MVC on your local machine several assemblies are registered with the GAC.
It may be that your host does not have all the required ASP.NET MVC assemblies installed; if not then you will see a configuration error.
As these assemblies are registered in the GAC, the bin folder will not contain them by default.
Make sure your project explicitly references the following DLLs and make sure the Copy Local property is true.
System.Web.Helpers
System.Web.Mvc
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
Microsoft.Web.Infrastructure
Rebuild your project and check the bin folder. These files should now be present.
Upload the contents of this folder to your host.
you have to copy the whole mvc project into httpdocs folder to view it online.
You are getting the 500 - internal server error may be because the mvc version differs in the server(i mean may be you are using mvc v4 and the server has mvc v2).
So just contact your hosting provider, i am sure you will get a good solution.
I had the same problem with an MVC5 app using ASP .NET 4.5. To solve it, I used the Visual Studio publish Tool (Image1) right clicking in the solution explorer.
Then the Web App was published successfully.
you copy the whole project into httpdoc , then u must enable wildcard ASP .NET mapping for the website , ask your hosting system admin , usually they can do that
I'd suggest (from Visual Studio) using the Publish utility to actually upload your website. Plesk Hosting offers support for Web Deploy which is probably your best option, or alternatively you can pick FTP. When you use Visual Studio's publish, it should (I think) include the dependencies you have (in case you had anything in the GAC)
Select the following assemblies:
System.Web.Mvc
System.Web.Routing
System.Web.Abstractions
In the Properties window, set Copy Local to True.
then upload bin folder in mvc to the server. this may fix the issue

Updating a DLL in a Production ASP.NET Web Site bin folder

I want to update a class library (a single DLL file) in a production web application. This web app is pre-compiled (published). I read an answer on StackOverflow (sorry, can't seem to find it anymore because the Search function does not work very well), that led me to believe that I could just paste the new DLL in the bin folder and it would be picked up without problems (this would cause the WP to recycle, which is fine with me because we do not use InProc session state).
However, when I tried this, my site blows up and gives a FileLoadException saying that the assembly manifest definition does not match the assembly reference. What in the world is this?! Updating the DLL in Visual Studio and re-deploying the entire site works just fine, but it is a huge pain in the rear. What is the point of having a separate DLL if you have to re-deploy the entire site to implement any changes?
Here's the question: How can I update a DLL on a production web site without breaking the app and without re-deploying all of the files?
The thing to remember is that there are web sites and web applications as far as Visual Studio and ASPNET is considered.
Web Sites typically have all of the aspx and vb files published to the live server and ASPNET Worker Process recompiles the app every time before presentation.
On the other end is the web application, where all of your code behind files get compiled down to a single DLL file and you simply deploy your aspx pages and you bin folder with the DLL file to production.
There is also a "hybrid" known as "Precompiled Web Sites" (see the link for the official MSDN overview) where you don't have the single DLL layout of a web application, but all the compile work of the website is done for you. There are several "modes" to this depending on your needs.
It seems to me that your error is caused because your site is set up as a web site with some kind of precompilation in place. Using the pre-compiled model is a little more "strict" in that is assumes certain files/signatures are in place. Having an updated version of the DLL file causes a break since the precompilation wants a name and a version of the file.
If possible, your best bet would be to convert to a web application, since you can add the additional DLLs into production without a problem. Otherwise, take a look at this matrix to see what form of precompilation you need for your application.
Look at this SO post, might be what you are referring to. The located assembly's manifest definition does not match the assembly reference
Have a look at your reference. Does it say "specific version = true" ? Set it to false, republish your app (you have to do it once, because now your app is still looking for an assembly with a specific manifest) and try it again.

Resources