Recently, my team converted ASP.NET project from .NET 1.1 to .NET 2.0. Everything is pretty good so far except for one web page.
This is the error message I got when I tried to open this page:
Server Error in '/' Application.
Parser Error Description: An error
occurred during the parsing of a
resource required to service this
request. Please review the following
specific parse error details and
modify your source file appropriately.
Parser Error Message: Ambiguous match
found.
Source Error:
Line 1: <%# Control Language="c#"
AutoEventWireup="false"
Codebehind="Template.ascx.cs"
Inherits="eReq.Web.WebControls.Template.Template"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"
%> Line 2: Line 3:
function
ExpandCollapse_Template(inBtn,
inSection, inSectionID) {
Source File:
/WebControls/Template/Template.ascx
Line: 1
-------------------------------------------------------------------------------- Version Information: Microsoft .NET
Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053
I tried renaming class and renaming filename but it didn't work.
Anyone have any idea on this?
It may appeared because of different names of components? for example Button1 and button1, it compiles as casesensitive, but executed as caseinsensitive.
In your ASCX file, go through each and every control and change its id. For example,
<asp:TextBox id="foo" />
change it to
<asp:TextBox id="foo1" >
You've probably got a control with an ID that matches a property in your ascx file, so when the compiler is trying to make instance variables its colliding.
I've the same problem and it solved and the solution is in check your code behind and you will find a couple of Controls with the same name:
protected Button Home;
protected System.Web.UI.HtmlControls.HtmlAnchor home;
you have to erase one line or comment it.
The selected answer seems to be the right one.
In my case i found that im using a variable in the codebehind with the same name as a control in the aspx file, just with different case usage.
I'd trawl your web.config for 1.1 and 2.0 references to the same DLL. In most cases that I have gotten this it was System.Web.Extensions.
Also check the #registers in Pages if that fails.
Good luck (it is not a fun bug to find!)
Dan
Same Name Id in aspx file and property inside aspx.cs file
when .aspx page and behind aspx.cs class contains Same property this kind of problem occur. When I am searching the solution for this problem.. not found any useful content. finally I solved the problem by renaming private property name to different inside aspx.cs class attached image as screenshot.
if anyone still facing the problem you may try
Screenshot 1
Screenshot 2
This is due to what can only be described as a defect in System.Web.UI.Util.GetNonPrivateFieldType(Type classType, String fieldName) that allows UI (.aspx/.ascx) fields to compile as case-insensitive but attempts to retrieve them as case-sensitive during the intial parse.
A potential remedy for the time being is to catch it at compile-time with an ms-build task.
Related
I'm getting the following error when using the New-WebServiceProxy cmdlet:
Could not load file or assembly 'file:///.dll'
or one of its dependencies. The system cannot find the file
specified.
The WSDL was perfectly valid. After many hours of debugging, I found out that this message happens because the C# code generated for the Web Service classes is invalid. I don't know exactly why, but it appears that this error will always occur when the following naming pattern is used for the Web Methods:
[WebMethod]
public void AnyMethodName(...) { ... }
[WebMethod]
public void AnyMethodNameAsync(...) { ... }
I'm not sure of what is really happening, but I can tell that changing the name of the first method will work, as well as changing the order that the methods appear within the class - that is, the first method cannot be placed just before the second method.
The exception is thrown inside the method GenerateWebServiceProxyAssembly when returning the value of results.CompiledAssembly, as you can see here.
Does anyone knows what is really happening? Is this a bug of this cmdlet? Are there any solutions other than renaming the methods or chaging it's order inside the class?
I know this is a recurring error but I can't seem to get around it.
Intellisense does recognize the name of my custom control and suggests to add the proper using: directives, but not only XAML designer doesn't find the name of the control but I can't get through compilation either.
The custom control is a public class defined as
namespace MyApp.CustomControls
{
public class CustomTextBox : TexBox
{
...
}
}
And in my MainPage.xaml
<Page ...
xmlns:customControls="using:MyApp.CustomControls">
...
<customControls:CustomTextBox/>
...
</Page>
This does not render in design nor compile.
This answer and the ones below are not working for me.
The error message:
Error XDG0008 The name "CustomTextBox" does not exist in the namespace "using:MyApp.CustomControls".
Your code should works well after you build the project, and it works well in my side using your above code. Try to clean your solution or delete the bin and obj folders in your project then rebuild your app again. Also try to restart your Visual Studio. If it still happens, you can provide a reproducible sample to help me look into this issue.
I've seen quite a lot solutions saying that you should rebuild the project, restart Visual Studio or restart the machine.
What worked for me was specifying the assembly in the namespace reference, that is:
xmlns:the_namespace="clr-namespace:the_namespace" - produces the above error.
xmlns:the_namespace="clr-namespace:the_namespace;assembly=the_assembly" - works well.
I got a version of this error in my embedded UserControl when I tried to use the Name property in my XAML instead of using x:Name. In other words, when my XAML code looked like this:
myUserControls="using:MyUserControls"
<myUserControls:GraphCanvas Name="GraphCanvas" />
I got an error that 'The name "GraphCanvas" does not exist in the namespace "using:MyUserControls"'. When I changed one line of code to this:
<myUserControls:GraphCanvas x:Name="GraphCanvas" />
Everything built just fine.
I'm dropping this solution here because it took me about a day and a half to figure out this problem and this was the only stackoverflow page I found when I searched the error string. Hopefully I will save someone else the hassle I went through.
I have in my ASP.NET Web Forms Application resx file localized in App_LocalResources\fr.aspx.resx with key value: hello_world.
Now I want to use it on my ASPxLabel on class Page.aspx, so I simply:
<dx:ASPxLabel ID="0" runat="server" Text="<%$ Resources:fr, hello_world %>"></dx:ASPxLabel>
but I have error: Parser Error Message: The resource object with key 'msg' was not found.
I am sure that fr.aspx.resx is publicated, but still got Parser Error. What I am doing wrong?
First of all check the name of your resource file. It has to follow the following naming convension
pageName.extension.language.resx
If you aspx page name Page.aspx, then the you should have resource files with the following name.(You can add resource files for further language and culture)
Page.aspx.fr.resx
Check whether you follow this convension or not.
To you this resource in the aspx page you have to follow the convension as below
<%$Resources:Class,ResourceID%>
where Class is the name of resource file, if it is compiled as class, otherwise this can be ignored.
ResourceId is the key in the resource file.
In your code you are setting the resource as below. Check whether the resource file has a codebehind with the class name fr.
Text="<%$ Resources:fr, hello_world %>">
For more details you can visit the following link
http://msdn.microsoft.com/en-us/library/ms227427(v=vs.90).aspx
I'm getting designer error on code:
The Component i'm willing to define a List of properties for:
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
namespace TestProjectForProperty.Test
{
public class MyTreeView : TreeView
{
private List<TypeDescriptorBase> _descriptorsAvailable = new List<TypeDescriptorBase>();
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<TypeDescriptorBase> DescriptorsAvailable
{
get { return _descriptorsAvailable; }
set { _descriptorsAvailable = value; }
}
}
}
The Descriptor itself:
using System;
namespace TestProjectForProperty.Test
{
[Serializable]
public class TypeDescriptorBase
{
public string Name { get; set; }
public override string ToString()
{
return Name;
}
}
}
I am getting the following error if i try to use the component for example on a form and add any items on the property sheet or in the component's constructor to the DescriptorsAvailable property
Error 1 Invalid Resx file. Could not load type
System.Collections.Generic.List`1[[TestProjectForProperty.Test.TypeDescriptorBase,
TestProjectForProperty, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 which is used in the .RESX file.
Ensure that the necessary references have been added to your project.
Line 134, position 5. ...\visual studio
2010\Projects\TestProjectForProperty\TestProjectForProperty\Form1.resx 134 5 TestProjectForProperty
In the Resx file there is data field with base64 encoded stuff inside when this error is present.
I have been searching for an answer, but the best i got is to restart everything, it didn't help me, do you guys have any suggestions? I'm using .net 4 client and visual studio 2010
In my experience, this is due to a change of version of a referenced library, or a change of the lib itself, which contains the backing type of a property you have defined in your user control. The solution is to "force" the visual studio designer to re-initialize it's designer code for that type, and not expect to retrieve a "canned" version of it from the .resx file of the control.
1) Delete the offending data section in the .resx file of your control. This will be a section in the xml of the .resx file associated with your user control, which has a node: <data></data> - the name attribute will be set to whatever you've named that object in the properties of whatever you added this type to. The <data>/data> section contains a base64 encoded string that is the encoded form of the name and version of the library the type comes from. This is where the problem ism, because it now contains an encoded version of the library and/or version number you are no longer referencing in order to include the type. Delete the entire <data>/data> section, from opening to closing tag, save the change and close the file. Now the "artifact" is gone.
2) Now find the place in the designer file for your control, where the type is instantiated; this is initialization code generated for you by visual studio, and it is the place that is expecting to load a "canned" definition of the type from the base64 encoded string contained within the .resx file. The line will look something like this:
this.myCtrlFoo.MyPropertyFroo = ((MyNamespaceFoo.MyTypeFoo)(resources.GetObject("myCtrlFoo.MyPropertyFroo")));
...now just replace the resources.GetObjec call with the instantiation of a new instance of the appropriate type like so:
this.myCtrlFoo.MyPropertyFroo = ((MyNamespaceFoo.MyTypeFoo)(new MyNamespaceFoo.MyTypeFoo()));
...now save the change to the file, close it, rebuild, and everything should now build & run OK.
Put the MyTreeView and TypeDescriptorBase classes into another project and reference it from your GUI project will resolve the issues.
I'm not sure why exactly the problem occurs - I guess it has something to do with the way the serializing process is generating the base64 string for the DescriptorsAvailable Property. Maybe somebody else can give us some insight.
I've struggled quite a bit with this; I have three user controls that all expose the same non-designer property, but for some reason, any change to two of the three would instantly cause the next build to fail with this same issue. This is in VS 2015.
I wound up having to add the following two attributes to the property that kept expanding in the resx file, and it hasn't occurred since. It works for me because they're not available in the designer anyway.
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
For me, this error occured when I used a custom class as a property for the user control. When I switched from property to traditional get- and set- methods, the error disappeared. I guess this is because properties are already compiled at design-time, so when you build the whole project, a new version of the custom class is compiled which is separate from the one of the control, and the reference is broken.
For me, with the custom class Inventory, all I had to do was to switch from this property-based approach:
public Inventory Resources {get;set;}
to this method-based approach:
private Inventory resources;
public Inventory getResources() { return resources; }
public void setResources(Inventory newResources) { resources = newResources; }
I hope this helps someone, as I've been spending some hours on figuring it out.
In my case I've got the error : "error MSB3103: Invalid Resx file. The specified module could not be found" executed in a light windows container based on mcr.microsoft.com/powershell instead of mcr.microsoft.com/windows:1909 (was working fine on 1909).
The error was on a ressource icon that was compressed with PNG inside.
It can be checked by opening the ressource on visual studio : Project > Properties > Ressources.resx, select icons, double click on the icon, check the end of the title that is either "..,BMP]" or "...,PNG]").
Updating the icon with an uncompressed format solve the "Invalid Resx file" issue.
I stumbled across this question today whilst looking for the solution to a similar issue.
Unfortunately none of the above worked for me, however my issue turned out to be that I had different versions of the .NET Framework for different projects. For example;
Project A - .NET Framework 4.7.2
Project B - .NET Framework 4
Where Project B was referencing Project A. Solution was simply to change the .NET Framework version of Project B to 4.7.2 (in my case) and hey presto the issue was resolved.
A shame Visual Studio doesn't provide a more helpful error message in this case, but something to look out for!
I am running asp.net, C#4.0 application in VS2010. I get the following compilation error:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Source Error:
Line 1: using System;
Line 2: using System.Collections.Generic;
Line 3: using System.Linq;
My page attribute is :
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
EnableEventValidation="false" Inherits="jsPlumb_jsPlumb_Default2" %>
my c#codebehind class:
namespace CompanyDisplay.jsPlumb.jsPlumb.jsPlumb
{
public class jsPlumb_jsPlumb_Default2 : System.Web.UI.Page
{
}
}
i want namespace to present for running some webservice applications.
Try to do this :
add batch=”false” in the compilation tag of your applications web.config file as shown below
compilation debug=”true” batch=”false”
clean solution
delete the temporary files folder in Visual Studio(the folder which it shows in the exception)
do an iisreset and the rebuild my code again
I got the ANSWER ; I should give the inherit attribute as;
inherits="CompanyDisplay.jsPlumb.jsPlumb.jsPlumb.jsPlumb_jsPlumb_Default2"
This error shows up when code-behind class name doesn't match "inherits" attribute on your aspx page. Maybe you tried to rename something?
Furthermore, I've seen this error, when you try to view a new page, but didn't compile the source, so even though your aspx exists, it can't fight the corresponding code-behind class.
Edit:
You have a completely messed up naming conventions, no surprise you're having troubles to match class names properly.
Sorry, but this is just preposterous!
inherits="CompanyDisplay.jsPlumb.jsPlumb.jsPlumb.jsPlumb_jsPlumb_Default2"
Fix your conventions and maybe you find yourself having source files like this:
CodeBehind="Default.aspx.cs" Inherits="MyNamespace.jsPlumb.Default"
Don't do it like jsPlumb.jsPlumb.jsPlumb....That's just a nightmare!