Archive for March, 2018

Type or namespace name could not be found when building in Release mode

When building a web application with Visual Studio in Debug mode, I wasn’t getting any errors. But when I switched to Release mode, I received this error:

The type or namespace name ‘ScottStuff’ could not be found (are you missing a using directive or an assembly reference?)

There was no conditional logic to exclude that ScottStuff library based on the configuration I was using.

The problem was that when I made the reference to the ScottStuff DLL, I had included it from a different directory, c:\SomeDirectory\ScottStuff.dll. To fix the issue, I instead referenced the DLL from the bin folder of the project I was working on, c:\Projects\ScottProject\bin\ScottStuff.dll. After doing this, the project compiled successfully.

Advertisements

Leave a comment

401 – Unauthorized in an ASP.NET project

While debugging a new to me (I didn’t write it) ASP.NET project locally, I came across this error when the default.aspx page loaded:

401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.

There are several reasons why this could happen, but in my case, it was because the application was set to reject unauthenticated users. In the web.config file, there was this section:

    <authorization>
      <deny users="?" />
    </authorization>

Disabling the <deny> tag resolved the issue.

Leave a comment

Entity Framework error: ‘The underlying provider failed on Open’

I was using the Oracle.ManagedDataAccess DLL to reference an Oracle database  using Entity Framework. However, attempting this was returning the error “The underlying provider failed on Open” when my object list was being populated:

List<COASTER> coasters = context.COASTER.Where(c => c.PARK== "Cedar Point").ToList();

The issue came down to my connection string format. When trying to use the normal format that we’ve come to know and love, I’d encounter the problem. The format I’m talking about is:

metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string='DATA SOURCE=ScottServer;PASSWORD=mypw;USER ID=scott'

However, when I switched to the format that you see in the tnsnames.ora file, I had better results. So good, in fact, that it actually worked:

metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string='Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=my-server)(PORT = 1521))(CONNECT_DATA=(SERVICE_NAME=testdb.www.wunderhund.com)));User Id=scott;Password=mypw;'

Leave a comment