Parse error in ASP.NET web forms application - c#

Four time in four days in four different projects I have received the following error (except different for project name). The projects all work fine while I am building the first couple of forms and then I go to lunch, go home overnight, etc. and then suddenly they throw this error. This last time, all I did was walk away for five minutes to take a leak.
How do I fix and prevent this? I am very new to ASP.NET, so don't know much on how to fix errors of this sort.
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: Could not load type 'PathCertLink.Global'.
Source Error:
Line 1: <%# Application Codebehind="Global.asax.cs"
Inherits="PathCertLink.Global" Language="C#" %>
Source File: /global.asax Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.6.1055.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
using System.Data.Entity;
using PathCertLink.Models;
using PathCertLink.Logic;
namespace PathCertLink
{
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// Initialize the database.
Database.SetInitializer(new ProductDatabaseInitializer());
// Create the custom role and user.
RoleActions roleActions = new RoleActions();
roleActions.AddUserAndRole();
}
}
}

Related

C# Generate SSRS Reports "reportservice2005 exception"

I have created a console application before that renders a report, and saves it as a pdf. I am now creating a new one following similar guidelines. When I try to run the program I get this exception:
An unhandled exception of type 'System.ArgumentNullException' occurred in System.dll
Additional information: Value cannot be null.
on this line of code:
ReportingService2005 rs = new ReportingService2005();
I am currently using these references, which are the same as in my other console app as well:
using pdfGeneration.severRef;
using pdfGeneration.ssrsExRef;
using System;
using Microsoft.Reporting.WinForms;
using System.Data.SqlClient;
If anyone knows how to solve this or why this is happening let me know! I am a bit confused as to why it is saying this value is null..
Using visual studio 2015
Thanks!
Update: There was an issue with the reference paths, I deleted them and reinstalled.

Access to path denied - IIS express - upload file -Windows 8.1

I know this error maybe very popular and there are many people asking about it. I have read through other threads but can not seem to find a solution applicable to my scenario.
I am new to ASP.NET programming, am using vs 2013 ultimate, IIS express on my laptop with Windows 8.1.
I have created a new website using WebForms and I was testing the upload function to my local machine running IIS express that came with VS2013.
My code behind is as simple as
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MyWebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string name = TextBox1.Text;
string type = DropDownList1.SelectedValue;
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/Content"));
}
}
}
Ran it and got this error:
{"Access to the path 'C:\\Users\\xxx\\Documents\\Visual Studio 2013\\WebSites\\WebFormDemo\\Content' is denied."}
I understand that it is an unauthorized access due to lack of privilege, but my question is how do I give access to my application? I have admin right on my machine, run it locally so the firewall should not be an issue. Some threads suggested to go to IIS manager and adjust the right to DefaultPool but I do not think I have InetMgr on my Windows 8.1,
How do I solve the unauthorized access for my case?

WebRequest.create causing SecurityException in a .NET 3.5 class lib, but not in .net 4.5

The following code breaks in a .NET 3.5 class library project, but not in .net 4. I'm stumped and would appreciate any ideas:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using NUnit.Framework;
namespace test2
{
[TestFixture]
public class TestClass
{
[Test]
public void Test()
{
var request =
WebRequest.Create("http://www.google.com");
Specific Exception:
System.Security.SecurityException : Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, ref StackCrawlMark stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(String requestUriString)
at test2.LaunchRequestInitializeIdsTestFixture.Test()
The answer, as the exception says, is Code Access Security (CAS). I am building my code from a network drive (hosted VM). In .NET 3.5 and below, the network drive has lower privileges. This restriction was turned off for .NET 3.5 SP1 and above. The following link put me on the right track:
http://blogs.msdn.com/b/vancem/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx
The following, run from caspol in the .NET 2 install dir got my code working:
caspol.exe -m -pp off -ag 1 -url "file:///Z:/*" FullTrust
I got the above command line from this helpful post:
https://julianscorner.com/wiki/programming/caspol_network_share
FYI:
to restore to defaults, just run "caspol -restore"

Why some or all identity references could not be translated

In the visual studio 2010, there is no error and everything works fine, but when I publish to IIS once an error
line:
Microsoft.Expression.Encoder.Preset pres = Microsoft.Expression.Encoder.Presets.VC1IISSmoothStreamingSD480pVBR;
error:
Server Error in '/' Application.
some or all identity references could not be translated
Description: An unhandled exception occurred during the execution of the current web request. Examine the stack trace for more information about this error and where it originated in the code.
Exception Details: System.Security.Principal.IdentityNotMappedException: some or all identity references could not be translated.
update:
I'm getting the same error from line:
var job = new Job();
namespace:
using System;
using System.Linq;
using System.Web.Mvc;
using Microsoft.Expression.Encoder;
using Microsoft.Expression.Encoder.Profiles;
using VideoSmooth.Domain.Abstract;
using VideoSmooth.Domain.Entities;
using VideoSmooth.Web.Models;
I set ApplicationPoolIdentity in pool iis and it worked without error

Cannot build project using Mono for Android

When i try to build and run my project i get the following build errors:
HourScreen.cs(13,13): Error CS0433: The imported type `System.Net.WebRequest' is defined multiple times (CS0433)
HourScreen.cs(17,17): Error CS0433: The imported type `System.Net.WebResponse' is defined multiple times (CS0433)
The lines on which the errors happen look like this:
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
I include the following into the project:
using System;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Text.RegularExpressions;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Preferences;
using Android.Graphics;
I think one of the includes must be playing up but i have no idea which. Removing one causes a huge load of other errors. Can anyone see where im going wrong?
EDIT:
I've included the build log: http://pastebin.com/FrmzfhcY
HourScreen.cs(167,17): error CS0433: The imported type `System.Net.WebResponse' is defined multiple times
/Developer/MonoAndroid/usr/lib/mono/2.1/System.dll (Location of the symbol related to previous error)
/Mono for Android/Bups_Urenverantwoording 1.0/Bups_Urenverantwoording/bin/Debug/System.Net.dll (Location of the symbol related to previous error)
The log has your answer. Mono for Android provides it's own System.Net stack in System.dll but you're also including other assemblies, like System.Net.dll which includes the same type.
Since you also reference System.Windows.dll I assume you're trying to include some code from Silverlight (or Moonlight) and that won't work. At least not for for System.Net.dll (not sure what you're trying to use from System.Windows.dll).

Categories

Resources