Adding a second <%#Register %> line to my page causes Compilation Error - c#

When I have just one <%#Register %> line in my page, it loads fine.
When I add a second one, it gives me this compilation error:
Compiler Error Message: CS0433: The
type 'ASP.test1_ascx' exists in both
'c:\Users\me\AppData\Local\Temp\Temporary
ASP.NET
Files\root\c2d75602\aae4f906\App_Web_dta-e2tq.dll'
and
'c:\Users\me\AppData\Local\Temp\Temporary
ASP.NET
Files\root\c2d75602\aae4f906\App_Web_layerwindow.ascx.cdcab7d2.zxul1sik.dll'
(slightly anonymized)
Any ideas?
EDIT: Additional information I just noticed: the line above the broken line in the YSOD said: [System.Diagnostics.DebuggerNonUserCodeAttribute()] When I searched for information on this, I found a page telling me to check to make sure I didn't have any open brackets I wasn't closing. Haven't found any yet, but this may be part of the issue.
EDIT: Argh. Just want to kill the computer at this point. After daughtkom suggested creating a new project to see if the code worked from scratch, I did that and it worked. I then decided to create a new control and copied the Test1 code into there... and then it started working. (No changes to Test1 or Default.aspx, just created Test1-2.ascx.) Then I added the link to Test2 into Default.aspx... and now it's giving me the same error, just with test2. And creating a Test2-2.ascx isn't fixing it this time.

Delete your temporary files or restart your webserver.

I ended up setting "<compilation batch="false">" in my web.config file, which fixed the issue. I found it from a MSDN article... somewhere. If I find the link again I'll post it.

check the class names in test1.ascx.cs and test2.ascx.cs.
check the Inherits attribute of test2.ascx

Delete all of the DLLs in the folder mentioned in the error message. Also, check to make sure that the code behind for test2.ascx.cs doesn't inherit from test1.

Related

Error when publishing dynamic module contents Sitefinity

When I try to update the dynamic module contents and click on publish it is showing a popup with message 'The type initializer for '' threw an exception' and I am not able to publish any content.
This is an inconsistent issue for me. It is weird that without doing any change at times this issues does not happen but it comebacks again. Can anyone please help me with this issue. Is this anything related to server update or server utilization because recently I added some more contents to the modules no other code changes or anything was done?
I found this link 'https://knowledgebase.progress.com/articles/Article/Uploading-images-error-Cannot-save-the-file-The-type-initializer-for-Module-threw-an-exception' but unfortunately, this did not solve my issue.

Error while generating view in Visual Studio 2019

While I am creating an ASP.NET MVC view in Visual Studio 2019, I am getting this error:
There was an error running the selected code generator: 'the value -1 is outside the acceptable range 0,2147483647
How can I solve it?
We have to open vs-2019 and select tool -> Options-> General -> ignore GPU memory access exception if the data written didn't change. Mark it as checked then error will be disappear.
I ran into the same problem tomorrow, tried many manipulations found on different subjects, including yours, nothing worked. Finally, someone gave me a "solution" that let me continue my project, hence I'm sharing it here in case yours doesn't fit someone's issue: simply copy/paste any view...!
Yeah, it doesn't make the resilient error go away, and you'll have to hand code each new view, but at least you'll be able to keep coding your project.
Hope this helps.
You might want to check out my answer to this in:
the value -1 is outside the acceptable range of [0,2147483647]. Parameter name: value

Null Reference Exception.....but the value is NOT NULL

I have a line of code string managerFirstName = "test#test.com"; that is flagging as NULL. How is this NULL....its a string that is populated when its created....is there an error with my VS2013? or a setting I need to change?
It's not the highlighted line that is crashing - the IDE is highlighting the wrong line.
The stack trace you posted mentions RFS.DotNetNuke.Service.ActiveDirectorySynchronise.something. Try and look for a line of code that uses that object - probably the line of code above the highlighted line (GetManagerForOrgUnit). Examine each of the parameters for that call and see if you can find a null reference.
If the problem is code related, not build, this looks like a threading issue. Try wrapping the whole function in a lock, and looking for how contexts could be getting mangled.
I have had this issue with VS 2022. Where this happens I get null reference and errors. I have found that this was because my debug configuration was set to Release and not debug.
Try after removing Visual Studio component cache.
Close Visual Studio (ensure devenv.exe is not present in the Task Manager) Delete the directory:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
Restart Visual Studio
This used to happen to me in VS2k13 a lot. Basically your code is not getting rebuilt. Even after a clean/rebuild, some code refuses to compile. What used to work for me was1. Clean/rebuild. 2. Make a code change in the area of code you are looking at. 3. Put a breakpoint in the calling method. 4. Debug and f11 step line by line to your code change.
Would just like to say thank you to everyone who helped me out with this Q....I found the cause...just above the
ADUser managerUser = GetManagerNameForOrgUnit(coreData.OrgAssignment_0001.OrgUnit.ID, coreData.PersonnelNo);
there is an if statement, which during testing always stops the code from hitting GetManagerNameForOrgUnit(), I have been manually stepping over this if.
I commented it out and the code works fine.
Thanks again
I faced this problem when I was manually skipping execution of few lines (apparently unrelated code section).

Error Deleting Document Type

I am getting a weird error on an Umbraco site I maintain. I'm trying to delete an old Document Type that I am replacing with an updated one. The error I am getting is:
Error handling action Item has already been added. Key in dictionary: 'textpage' Key being added: 'textpage'
The document type is not called "textpage" and doesn’t have any link to "textpage" that I can see. There are no physical files on the server and this error didn’t happen on the staging site nor did it occur on my local test. So I am a little stumped!
Any suggestions?
EDIT: This is also occurring if I try to save any document type in the CMS.
It could be a cache issue. Try touching the web.config file and see if the issue goes away.
Another thing that can cause this is if you have multiple templates with the same alias. Check for that as well.

"Invalid postback or callback argument" after new deployment

Recently deployed a project into production and have run into the "Invalid postback or callback argument" error. We haven't encountered this in testing at all and after some research have found that the problem occurs in the following situation:
Old version is published and accessed.
New version is published and accessed without clearing the Temporary Files.
Drop down is changed twice. (The first time everything works fine.)
The fix for the clients that have called in has been to clear their temporary internet files but this isn't the ideal fix. Can anyone think of a reason why this would be happening and stop happening after the temp files have been cleared?
BTW: The app is ASP.NET 3.5 written in C#. We're using a javascript call back in this particular control that's causing this issue.
We didn't want to use the "enableEventValidation=false" trick as this isn't a consistent issue. From pretty early on, we were able to fix the issue case by case by clearing the temp files.
After some more looking today it was suggested that we rename our js file and behold, the issue is resolved locally. Seems that each user has had our old js file stored.
As to why it was throwing the "Invalid Postback" rather than a javascript error, we're not sure. There are other ways of specifying the version number in the script tags but for now we opted for the rename.
Since you mentioned that you're using a javascript callback, this may be related to event validation. If that's so, there is a workaround for that problem which is adding the following line to web.config:
<pages enableEventValidation="false"/>
So that, event validation is disabled in your pages. To turn it off is not recommended for security reasons because it verifies that arguments are originated by the server control.
You can get detailed information here about why this error occurs.

Categories

Resources