I am using the ResourceManager in my C#/WPF desktop application to get localized resources (strings mainly). Furthermore, I am using the ResXFileCodeGenerator to generate a class which retrieves the resources in the UICulture.
Now my application installs all of its libraries (except the UI libraries) in the GAC (Windows\Microsoft.NET\assembly\GAC_32).
For each library a LibraryName and LibraryName.resources is installed. My application can either run with a GUI or from the console. There are two solutions for this. The UI application uses the UI libraries and the other only the libraries containing the logic.
With the UI application everything works well. If I set it to English, it shows everything in English. If I set it to another language, it shows everything in that language.
However, the console application shows everything in English, no matter which language is set. When debugging, I can see that the UICulture is set correctly and that it is correctly recognized, but somehow the ResourceManager does not retrieve the localized resource.
When debugging I can also see that the ResourceManager has a field called "_lookedForSatelliteContractVersion". This is set to "false". In the working case it is set to "true".
What can the problem be? Something with the references of the Console solution? Something with the solution settings of the Console solution?
I have a website which is build in Classic ASP. This website has a web.config file. I never created it, and never knew Classic ASP sites could have a web.config file, but this might be from IIS7 to store settings there.
This website uses a C# class library (DLL) to do some stuff. But here comes the tricky part. Should the DLL be able to read the web.config of this website?
I've copied the configSections from my app.config (from within the solution) to the web.config from the site. And also copied some settings (connectionstrings and applicationsettings). But when I changed the connectionstring to a faulty one, it would just keep running without a problem.
When I placed the configsections on the bottom of my web.config, the website wouldn't load because of a faulty web.config, so I the webserver is doing something with it. But can a C# DLL read this file also eventhough it's not a .NET website?
Thanks in advance.
As Chris said, asp classic does not use it, so it must have been created by IIS7 (or someone putting it there as a joke). That its not used if confirmed by your changing settings having no effect.
When you copied sections, the file becomes an invalid config; it's probably that which is causing it not to run, though what's checking it I don't know.
Another possibility is that the ASP website is using a C# library via COM Interop, and the run-time is checking its validity when it starts.
I have a particular web application. Half the time when I run it, I get the following error:
"ErrorCode": "FileNotFoundException",
"Message": "Could not load file or assembly 'MyNotReallyMissingAssembly, Version=1.0.0.0, Culture=en-us, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
I have narrowed it down a bit. If I either manually delete the Temporary Asp.Net files that correspond to this site, or changing a dll name and then change it back, or deploying a newly built dlls. Then it will work fine - until I change the web.config or run iisreset. Once that happens, I get nothing but the error mentioned above until a new build is deployed, or I clear out the Temporary Asp.Net files again.
I mention that this is a ServiceStack web service if it helps. I suspect that it doesn't matter though.
I know changing dlls, changing the web.config, recycling the app pool, and probably a few other things cause the web site to recompile, However, what I didn't know is that changing the dlls seems to do something quite different than simply changing the web.config or forcing an app pool recycle.
I looked around for this issue but couldn't find anything except this: http://support.microsoft.com/default.aspx?scid=kb;EN-US;823196. So I made a new .net 4.0 app pool and changed its identity to NetworkService and made sure the NetworkService user had full access to C:\Windows\Temp. (Note: the server is a Windows 2008 server). The problem still occurs.
Q: What am I doing wrong? What can I do to make sure that my app will continue working through application pool restart/recycle events, and web.config changes?
One of our clients has installed our web application into production.
We need to do a very quick patch to one of the aspx controls. I tried dropping the ascx and ascx.cs source files into the dir and unsurprisingly I got this error:
Exception type - HttpParseException - The base class includes the field 'foobar', but its type (UserControls_Controls_FOO) is not compatible with the type of control (ASP.usercontrols_controls_foo_ascx).
Yes, this approach is never a good idea, but is there anything I can do to the control to get it to run in the site instead of the version compiled into the DLL?
Doing a fresh install is not an option at this point.
no , you need to get it into compiled DLL and fresh deploy only then you can see the patch working
If you changed only ascx file you must update only it.
But if you updated ascx.cs you must Publish project and replace old bin directory with new one.
Also you can transform site to set of dynamically compiled pages, but it is hardcore old way and bad idea nowadays.
I am experiencing an error that I am unable to resolve for some time now. I was wondering if someone can help identify the cause of this error? I am completely new to asp / asax. After some research, I think that the error I am getting is due to the web application trying to use outdated code. I was thinking to rebuild the c# file using Visual Studio and/or the entire project. However, I am completely new to C# and asp, and was wondering can give me some suggestions if this may fix the problem and/or if there is an possible alternate solution.
Error message
Parser Error Message: Could not load type 'Inventory1.Global'.
Source Error: <%# Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>
Entire Global.asax contents:
<%# Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>
Try replacing CodeBehind with CodeFile
Could not load type
means that a type could not be loaded. (In this case, "type" refers to Inventory1.Global). Types are located in compiled DLLs. So, either the DLL isn't available, is out of date, or doesn't contain a public type with the given name.
Some possible causes are:
You have no type declared with the given name. For your example, you should have the following:
namespace Inventory1 {
public class Global {
...
}
}
Note: avoid names like Inventory1. They imply that there is an Inventory2, Inventory3, etc., which is bad practice as they're abmiguous and not very descriptive. Also, Global is pretty vague, and may introduce confusion with the global namespace.
Make sure your cases match (Inventory1, not INVENTORY1.)
You haven't compiled the project. In VS, rebuild the solution.
The assembly that declares the class has a compilation error, so the relevant DLL is either missing or out of date. Make sure you've resolved all errors.
The class is not marked as public.
If I had to guess, I'd put my money on a compilation error. Unlike PHP and other interpreted languages, C# have to be successfully compiled before they can be used.
I had this error , just needed to rebuild the project
I faced this issue and i got the solution from here and i would like to share it.
SOLUTION
Empty the bin folder. Build all the dependent class libraries and refer them in the main project and build the complete solution.
I did this and it worked like a charm for me !!
After scouring around for what could have caused this I found a few things that I needed to do to get my project running...
(Note: You may not need to do all of these - it is a case-by-case thing)
If you did any changes from IIS Express to Local IIS you may need to change the build configuration from bin/debug to bin. (Right click on solution >> Properties >> Build >> Output)
If you have a URL rewrite then you will need to install URL rewrite on your Local IIS.
Navigate to your applicationhosts.config file (usually it's some place like C:\Users\username\Documents\IISExpress\config) and rename the file to applicationhostsOLD.config.
Clean and rebuild your project. You may need to go manually empty out the bin.
Now you should be good to go.
Since it was only happening with IISexpress, changing output from bin\Debug\ to bin\ solved it for me. Changing tag CodeBehind to CodeFile only created even more problems.
This happened with me on my local machine. The issue was incorrect IISExpres config.
If you are getting this issue on your local environment (Visual Studio debug runs), check the IIS Express config file. Make sure your local site/application path is pointing to the correct location.
The configuration file is called applicationhost.config. It's stored here:
My Documents > IIS Express > config . Usually (not always) one of these paths will work:
%userprofile%\documents\iisexpress\config\applicationhost.config
%userprofile%\my documents\iisexpress\config\applicationhost.config
It can't find the necessary file in dll assembly.
Rebuild the project, Rebuild the solution and then try it again.
I added a new build profile and that defaulted to output of
/bin/[new profile name] and when i was running debugger it was trying to look to just /bin
It's likely that you renamed something. Check the Global.asax.cs file for the class declaration and make sure that the namespace and class name match exactly what's in the asax file. This includes case! Can you copy/paste the namespace and class declaration of the .cs file into a post here so that we can compare?
Parser Error Message: Could not load type __
After doing everything suggested in the comments above, with no luck, refreshing (uploading) the contents of /bin to the server worked. The files uploaded to bin are the: dll, pdb and xml. Don't know which one did it.
The problem I had here was induced by renaming a file (_.aspx) in Solution Explorer.
Rebuilding/re-publishing my project/solution to the server did nothing to help me, and I doubt that will help that many out of this predicament. For me, I did a few things to troubleshoot this that eventually got me out of this "hole".
I had been trying to use a binding on the web site, but this wasn't working. I tried calling the site with http://localhost/Report.aspx (this was my homepage, which I opted to not call Default.aspx - I was going to update the "Default Documents" section with the name later) when I got the Parser Error the OP saw. So I tried some things:
I stopped the old project's website and built another, simple web project, that had "hello" and a label on the page and nothing else. I had a line in the Page_Load to populate the label's Text property with "world!", just to make sure that part was working. I created a new website on port 80 and transferred the published contents of my site to the server. So even though I had .NET 4.5 installed on the server (and had ran the aspnet_regiis -i command from the 4.0 directory) and the App Pool in IIS that I was using for this new project was set to 4.0, the browser complained about the web.config having a targetFramework=4.5.2 in it, which is Visual Studio 2015's default framework. So I installed .NET 4.6 (NDP46-KB3045557-x86-x64-AllOS-ENU.exe), restarted the server, and then my simple site worked. So then I deleted this site - all I wanted to do was prove my installation steps were accurate and the server could run a site.
So then I went back to my original project/site - I deleted and re-created the web site. I put the Application Pool to the one I had originally created for this, which I ensured was running .NET 4.0. Once I did this, I navigated to my site and everything worked when using http://localhost/Report.aspx. So it seems to me what causes this is what version of the .NET Framework you are using.
I tried all the solutions listed above and none of them worked. I finally created a new web page (webform) and copy blocked all the code (cs and aspx files) into it from the old one, deleted the old cs and aspx file, recompiled, and now I'm back in business. I know it makes no sense. It should not have mattered, but it worked.
Please try to open your project as Project/Solution, most probably it will resolve the error. This type of error Could not load type.... occurs when we try to open project as website.
I have tried to open my project as solution and it resolved my problem.
Please check namespace and class name at all places, In one case, One team member changed namespace and I was using old namespace in .aspx file. It was causing issue. I updated namespace and it got working.
I was fixing my namespaces in our Base Project, and I started seeing this error on another project that references it after that. I had to remove the reference to the Base Project and re-add it and then it started working again.
I just got this error today. It turns out that it was because I reverted by mistake the project file to an older version that didn't include the page anymore.
I had the same issue after renaming an aspx page Visual studio renamed it but dropped the namespace. Make sure the Inherits property contains the fully Qualified name including the namespace.
If you just added the new aspx File, rebuild the project it is located in. The problem comes from your Code Behind file that isn't compiled at the moment, therefore you want to access a newer page that doesn't exist in your current compiled project dll
I had this problem on the remote server, but not on my local server. After trying everything and nothing working, I finally resolved it. My domain name was pointing to a directory under another domain. I had originally built the website independently in Visual Studio as its own project. No matter what I did, it wasn't working anymore. So I moved it to a folder inside of the project for the main domain name and uploaded it as part of the main project.
For example, I have say domain name AAA.com with a website of its own. And then I also have BBB.com that points to a directory under AAA.com's main directory. Originally I had separate VS projects for AAA.com and BBB.com, but that wasn't working anymore. So I had to move all of BBB.com's files to the AAA.com project and set it up exactly like it appears on the remote server. For some reason, that worked.
Try This It will Definitely work :-
Parse Error:
May be you Class name is not matched with the webform name