Schema specified is not valid. Errors: error 0002: Request failed - c#

I have an EntityFramework project running off MySql that runs great locally as well as on a dedicated server, however I'm trying to move this project to HostGator and I'm receiving the following error:
Schema specified is not valid. Errors:
App_Code.WireWeld.ssdl(2,88) : error 0002: Request failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors:
App_Code.WireWeld.ssdl(2,88) : error 0002: Request failed.
I know the database is correct as I can connect via Navicat and see its contents. I'm pretty sure the connection string is correct, I have the proper username and password.
I'm really stuck on this one and would appreciate any help possible.

If you are using more than one model in your project I advice you to have a look into that topic as it describes possible solutions to the problem.
If you are not using multiple models than this looks like a file permission issue to me.
Perhaps in the hosted environment, the account underwhich your application is running doesn't have access to where the metadata files are located?
You should make sure you have permission (read/write are required). If this is not an option for you than the only go would be to embed the metadata in the assembly directly and use a res:// style connection string.

If you're using SQL server and have 2 projects - one is a class library and the 2nd one uses that class library in main project, then place both dll from class library project to main project refrence.
1-EntityFramework.dll
2-EntityFramework.SqlServer.dll

Related

XmlException and CryptographicException when running blazor web server app

I receive these two exceptions when I run my blazor web server app:
XmlException: Root element is missing.
CryptographicException: An error occurred while trying to encrypt the provided data. Refer to
the inner exception for more information.
I just created the project and run it... I didn't write any piece of code .
Any help is appreciated because I didn't find any solution till now.
I have found two solutions to fix this issue if someone faced it later.
links to solution:
https://github.com/dotnet/aspnetcore/issues/12830#issuecomment-517907537
https://github.com/dotnet/aspnetcore/issues/12830#issuecomment-606173185

Instantiating .NET Print Server

Final Edit
Apparently I've been barking up the wrong tree.
https://msdn.microsoft.com/en-us/library/system.printing.printsystemjobinfo(v=vs.110).aspx
“Classes within the System.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.”
Edit
I haven't been able to get the .NET print server code to work. We have a collection of web services that perform small steps in a workflow, one of them is to print PDFs. I need to be able to send requests to a print server via .NET without having the print drivers installed the web server hosting the web services. Is there even a way to do this? If so, could someone point me in the right direction?
Original ?
I'm trying to connect to a remote print server in a different domain with the following code.
ps = new PrintServer(#"\\scanprn01",PrintSystemDesiredAccess.AdministratePrinter);
Every time I do so though, it throws the following Access Denied error. I've verified the account I'm using (via System.Security.Principal.WindowsIdentity.GetCurrent().Name) and that account is an administrator on the print server and has explicit full permissions to all the printers. Any advice?
Access Denied Error
System.Printing.PrintServerException was unhandled
HResult=-2147024891
Message=An exception occurred while creating the PrintServer object. Win32 error: Access is denied.
Source=System.Printing
StackTrace:
at System.Printing.PrintServer.Initialize(String path, String[] propertiesFilter, PrinterDefaults printerDefaults)
at System.Printing.PrintServer..ctor(String path, PrintSystemDesiredAccess desiredAccess)
at StubBP2Tester.frmBP2Tester.btnConnectPQ_Click(Object sender, EventArgs e) in C:\vsworkspace\StubBP2Tester\StubBP2Tester\Form1.cs:line 36

Server Error in '/' Application using Azure

The problem is that the web page was not deployed after migrating using another computer and also, the migration file was deleted.
the error was
The model backing the 'ProjectContext' context has changed since the
database was created. Consider using Code First Migrations to update
the database
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model backing
the 'ProjectContext' context has changed since the database was
created. Consider using Code First Migrations to update the database
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
is there any way to solve this problem from my computer? or there is another problem behind this?
What the message says is that your database model is out of sync with your Entity Framework 'Code First' model / code.
To overcome this issue, you can use Code First Migrations. The linked tutorial on MSDN explains what you should do. You effectively have to use the Package Console and some C# code to migrate one version to another. This is something you have to do while coding the project. If you release it, the code can automatically update your database model to match your Entity Framework Code First code.

Type Initializer Error Thrown by linq2db InformixDataProvider when run in Web Application but not Console

I am trying to use the linq2db library (thanks by the way!) to retrieve records from an Informix database. I followed the steps from the documentation and was able to successfully get records from an ASP.NET console applicaiton using the Visual Studio debugger. However, I then tried to follow the same with a fresh and standalone ASP.NET MVC5 application and I am getting the error "The type initializer for 'IBM.Data.Informix.IfxDecimal' threw an exception." also running using Visual Studio debugger. I did some digging by downloading the source code and adding some break points and found that Line 125 and line 133 of the file LinqToDB.DataProvider.Informix.InformixDataProvider file are involved in causing the error. But that is as far as I got. So running in the context of a web application throws an error, but running in a console application is fine.
below is line 125 of LinqToDB.DataProvider.Informix.InformixDataProvider
MappingSchema.AddScalarType(_ifxDecimal, GetNullValue(_ifxDecimal), true, DataType.Decimal);
below is the GetNullValue method in that class (lines 130 to 134 of same file), error gets thrown on return getValue.Compile()()
static object GetNullValue(Type type)
{
var getValue = Expression.Lambda<Func<object>>(Expression.Convert(Expression.Field(null, type, "Null"), typeof(object)));
return getValue.Compile()();
}
Additional Info..
In the documentation titled Informix Client Software Development Kit (Version 4.10) in Table 2-1. Best-fit types for retrieving Informix data types it shows that there are three DECIMAL Informix types, each map to three different suggested .NET types
I am afraid you can't use Informix in partial trust environment. When I try to create IfxConnection in partial trust, I get SecurityException - 'That assembly does not allow partially trusted callers.'
Too old to comment, but, I had this error too. Solved it placing getValue.Compile() in place of getValue.Compile()();.
Works fine now.

Nerd Dinner returns 404s for all sub-pages

I just got a new Windows Server 2003 machine and I've been trying to get Nerd Dinner onto it. The server already has .NET 3.5 SP1, ASP .NET MVC, etc.
When I upload Nerd Dinner via FTP to a subdirectory of the main webpage, I get a 404 when I go to any page in the site except for the root and the home page doesn't event show the map.
For example, when I go to the about page, I get the following IIS log entry:
2009-08-13 17:56:10 128.200.123.118 GET /nerddinner/Home/About - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip>) 404 0 3
I'm extremely puzzled because this is a freshly downloaded and compiled copy of Nerd Dinner from Codeplex.
In case it helps, here's a log entry from the failed attempts to get the JavaScript for the map (note the complete lack of "/nerddinner"):
2009-08-13 18:03:05 128.200.123.118 GET /Scripts/Map.js - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip>) 404 0 3
I have a strong feeling that I should be able to fix this inside the asax.cs file but I can't quite get it to work even after appending "nerddinner/" to the front.
Any ideas for what's happening?
Edit: I uploaded it to the root of the webfolder and the 404s continue.
Edit 2: Thanks for the suggestions. I followed the instructions and now I don't get 404s. However, there are 2 major problems left:
The scripts and content folders don't map correctly. I get 404s on all references to the files inside those folders.
I can't view dinners at all. I get:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
and a line in red that says "<connectionStrings configSource="ConnectionStrings.config" />". Except that ConnectionStrings.config doesn't exist on the server, so it wasn't an important file according to VS, and thus, I have no idea what the error is referring to.
(a quick search of my local hard drive turns up a ConnectionStrings.config file with nothing in it)
Edit 3:
Now I think I'm getting the equivalent of a SQL Server 404 when I go to view dinners...
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Summary To Help Others Running ASP .NET MVC on IIS6, Especially Nerd Dinner:
IIS 6 may throw piles of 404s at you because it doesn't understand that files can have no extensions. To solve that, follow the steps in Phil Haack's blog post.
ASP .NET MVC URL rewriting is not magic. It only rewrites URLs that are piped through code. References to scripts, images, databases, direct links (aka a href tags; not the ones that are dynamically generated) etc. are not remapped based on the directory of your application. For the Nerd Dinner application, go through the pages and add "/nerddinner/" in front of references to these references. Substitute "nerddinner" with the name of your subdirectory.
Take the database and attach it to SQL Server (or SQL Server Express) on your server. Add the Network User to the database with read/write roles.
Fill in the correct connection string for your setup. In my case, I was referring to the server by IP address and using SQL Server 2005 so my connection string is:
<add name="NerdDinnerConnectionString" connectionString="Data Source=128.200.123.118; Initial Catalog=NerdDinner; Integrated Security=SSPI" providerName="System.Data.SqlClient.SqlConnection"/>
Are you running it on IIS6? If you are, you will need to patch the route table to take into account the .ASPX extension, which IIS6 more or less requires.
Phil Haack has a good walkthrough that explains this process. He also explains ways you can do it without the .ASPX extension:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
The scripts and content folders don't
map correctly. I get 404s on all
references to the files inside those
folders.
In ASP.NET MVC files do not map one for one to an URL, like they do in ASP.NET. Instead, a match in the routing table diverts a GET or POST request from the browser to a controller method in one of your controllers. From there, the controller decides (either explicitly or by convention) which View to display.
An error occurred during the
processing of a configuration file
required to service this request.
Please review the specific error
details below and modify your
configuration file appropriately.
ConnectionStrings.config needs to exist on the server, since it is being referenced in web.config. It's an include file, so there doesn't necessarily have to be anything in it. But if it is being referenced, it needs to be included on the server, so just copy it there with your FTP program.

Categories