Active Record and Linq T4 Templates problem - sqlite

I've started a C# web application project using subsonic 3.0.3 as my DAL and SQLite for database.
It doesn't have any problem when using SimpleRepo, but the problem occurs when I try to use ActiveRecord/Linq T4 templates.
It says "Metadata file 'System.Data.SQLite' could not be found". The settings.ttinclude is the one provided with SQLite.ttinclude file and its config looks ok, and other files are instructed to use SQLite.ttinclude of course. I've also tested them with an SQL Server database and everything goes fine.
Also tried searching about it on the net and all I could find were these:
Subsonic Google Groups which instructs me to add a reference to System.Data.SQLite to the top of settings.ttinclude. No luck.
Someone at here commented about this issue, and it was answered to check the connection string, which doesn't seem to be my problem, because the app works when I use SimpleRepo.

Is SQLite installed on your machine? You need the .NET driver for it as well (that's what can't be found).

Related

Unable to load the specified metadata resource still comes

Yes, I know, this is the n'th question around this issue. I tried a lot of mentioned ~solutions, but none of them worked for me.
Windows 8.1, Visual Studio 2012, .NET 4.5.51641, Entity Framework 6.1.1
My struggle is to configure a well structured ASP.NET project, separate the different entities. I need more entities and in separate folders because of some overlaps among generated class names.
Therefore I've created a DAL folder and the first one, the Production. My model is quite simple, during the mode creation I've created the ProductionEntities entity connection string as it seems bellow:
Here is the ProductionModel.edmx and its properties:
I checked the assembly with reflector, all the resources are correct:
After that I've created a webpage and an EntityDataSource within it. If I select the ProductionEntities for Named Connection, I get above mentioned error message.
Have anybody some fresh idea for this? Thanks in advance!
I've got the solution!
After creating the entity model, it is MANDATORY to compile the project! After compilation the VS is going to recognize the entitydatasource wizard works fine...

ASP.NET and MySQL Connector Net

I am using latest version of MySQL connector Net to connect to a MySQL database from an ASP.NET form. I have copied the files MySql.Data.dll, MySql.Data.Entity.dll and MySql.Web.dll in the Bin folder of my ASP.NET application. Also I have imported required libraries using these lines:
Imports MySql.Data
Imports MySql.Data.MySqlClient
The image below shows the code and the error that I am getting:
What is wrong with the code please?
I have found a sample, this might help. Click HERE for example describes using ASP.NET/MySql.Data to connect to a MySQL Database.
No idea where dataset came from, should be database=dbherpes.

rdsserver.datafactory converttostring failure

I have a classic ASP application written many years ago that I'm trying to fix.
The following lines recently stopped working after w7 sp1 was applied.
set address = Server.CreateObject("ADOR.Recordset")
count = lo_connection.GetRecordset(sql,address,false, error)
Set RDF2 = Server.CreateObject("RDSServer.DataFactory")
Set teststring = RDF2.ConvertToString(address)
It fails on the last line there saying "Microsoft VBScript runtime error: Class doesn't support Automation"
A bit of searching found several articles like this one
http://blogs.technet.com/b/asiasupp/archive/2011/03/14/changes-in-mdac-adodb-com-components-in-windows-7-service-pack-1.aspx
that described the problem exactly. Where I am failing is that none of the suggested fixes seems to fix the problem. Any suggestions?
The solutions described in the link are not relevant here, since ASP is not early-bound - it uses OLE Automation. It might be worth re-registering the component which creates RDSServer.DataFactory objects (which is C:\Program Files\Common Files\system\msadc\msadcf.dll on my machines).
I looked up this object, and I found this Microsoft web page:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681447(v=vs.85).aspx
"This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Applications that use RDS should migrate to WCF Data Service."
Doesn't sound too good.

"Parser Error Message: Could not load type" in Global.asax

I'm working on an MVC3 project and receive the following error:
Parser Error Message: Could not load type 'GodsCreationTaxidermy.MvcApplication'.
Source Error:
Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="GodsCreationTaxidermy.Core.MvcApplication" Language="C#" %>
The error I get is cannot load GodsCreationTaxidermy.Core.MvcApplication but in this screen shot the Core part isn't displaying in the error:
Does anyone have any ideas or a solution to this error?
Check that the project output path (project properties / Build) is set to bin and not bin\Release or bin\Debug
For some reason IIS (VS development Server or Local IIS) always accesses the libraries from the bin directory (and won't look up for subdirectories)
Your local web server is running different code than what you're actually working on. Ensure you have stopped debugging, stop your local web server, clean and rebuild as Peter suggested, double-check your global.asax and global.asax.cs, and try again.
If this doesn't work and you are using local IIS, try removing the site in IIS Manager and recreating it manually.
Try modifying your global.asax file (simple add a space somewhere) and re-run. this will force the built in webserver to refresh and recompile the global.asax file.
Also do a clean and rebuild - should fix the problem
This happens sometimes if you change namespace information (project or class level) after the global.asax is generated.
Right click on the Global.asax file and select "Open With" and then select "XML (Text) Editor with Encoding" (other editors may work as well, but this is what I use).
Then edit the "Inherits" section in the XML directive
<%# Application Codebehind="Global.asax.cs" Inherits="GodsCreationTaxidermy.MvcApplication" Language="C#" %>)
so that it matches the actual full name of your Application class. And that's it.
Another option is to copy off all your code from Global.asax.cs and then delete and create another Global.asax file (and then copy the code back into Global.asax.cs).
I closed and reopened visual studio and it worked.
I had to go to BUILD -> CONFIGURATION MANAGER and -- ahem -- check the box next to my project to ensure it actually gets built.
I had this issue today, and it took me a while to find the cause.
Basically, my main VS2015 project was including a sub-project which had been built using a higher version of .Net Framework.
Bizarrely, when you have this problem, VS2015 will happily report that the solution has built okay, but when you try and run the website, it just gives you that misleading error, suggesting that your Global.asax.cs file is wrong.
So, if you see this error, and Cleaning/Rebuilding doesn't help, open your Project's References tree, and check for exclamation marks.
Also, check your Output window for messages like this:
The primary reference "C:\Projects\Business Objects 4\bin\Release\BusinessObjects.dll"
could not be resolved because it was built against
the ".NETFramework,Version=v4.5" framework.
This is a higher version than the currently targeted framework
".NETFramework,Version=v4.0".
The solution, of course, is to right-click on your main project, select the top tab, "Application", and change the Target Framework version to a higher version which matches your sub-project.
It's annoying that Visual Studio 2015 will let you fully build and run Solutions which quietly contain this problem. It's asking for trouble..!
"BUILD -> CONFIGURATION MANAGER and -- ahem -- check the box next to my project to ensure it actually gets built."
That and going to the project folder in windows explorer, pressing options and unchecking the "Read only" checkbox helped.
I just encountered this on an MVC5 application and nothing was working for me. This happened right after I had tried to do an SVN revert to an older version of the project.
I had to delete global.asax.cs and then added a new one by right clicking Project -> Add New Item -> Global.asax and THAT finally fixed it.
Just thought it might help someone.
I was working on an older 'folder based' ASP.NET web project (which I loathe) - and found this to be my fix:
Create an App_Code folder (if you didn't have one already)
Move the Global.asax.vb file into the App_Code folder
The markup in Global.asax can leave out any namespaces (at least, for this style of project, afaik):
<%# Application Codebehind="Global.asax.vb" Inherits="MyApp" Language="VB" %>
...where "MyApp" is the name of the class being defined in Global.asax.vb
Delete the .vs directory from the solution root. Clean. Rebuild.
This issue drives me bonkers once in awhile and I inevitably end up here paging through answers. I suspect there are multiple causes that can produce this exception, this once works for me.
You can also check your site's properties in IIS. (In IIS, right-click the site and choose Properties.) Make sure the Physical Path setting is pointing to the correct path for your application not some other application. (That fixed this error for me.)
Empty the bin folder. Build all the dependent class libraries and refer them in the main project, and build the complete solution.
Source
I have to report that I tried at least 4 suggestions from this post. None of them worked. Yet I am happy to report that I recovered by retrieving from back up. Only had to update my last code changes from log file. Took less then 10 minutes. Spent 3 times that reading this post and trying other suggestions. Sorry.
It was a very weird error. Good luck to anyone else encountering this gremlin.
I have same problem when I have 2 instance of Visual Studio running same project. So I closed both Visual Studio and opened only one instance and It works fine now!
This issue I was solved by giving right permission of the folder as well as check from IIS.
I was given permission to everyone as I am testing in my local environment. But in publish mode I think we give only permission to ASP.Net user.
I too faced the same problem. Despite of following every Answer it didnt work.
Then I changed the "Inherits=namespace.class" to "Inherits=fully qualified assemble name" i.e "Inherits=namespace.class,assemblyname, Version=, Culture=, PublicKeyToken="
Hope it helps.
This can also happen if you accidentally forget to set your VS solution to "Multiple Startup Projects" if you are running a Web and WebApi from the same solution.
You can check this by right-clicking on Solution in the Solution Explorer and select 'Properties". Then look for 'Startup Projects'.
I spent multiple days on this issue. I finally got it resolved with the following combination of suggestions from this post.
Change platform target to Any CPU. I did not have this configuration currently, so I had to go to the Configuration Manager and add it. I was specifically compiling for x64. This alone did not resolve the error.
Change the output path to bin\ instead of bin\x64\Debug. I had tried this several times already before I changed the platform target. It never made a difference other than getting an error that it failed to load the assembly because of an invalid format.
To be clear, I had to do both of these before it started working. I had tried them individually multiple times but it never fixed it until I did both.
If I change either one of these settings back to the original, I get the same error again, despite having run Clean Solution, and manually deleting everything in the bin directory.
The solution for me wasn't any of the above.
I had to delete (and not recreate) Global.asax and Global.asax.cs.
These files existed in the folder, even though they weren't referenced in the project.
Apparently the build still saw them.
Since I use OWIN with Startup.cs, the Global.asax file was obsolete and there was no issue with deleting it.
Yes, I read all the answers. However, if you are me and have been pulling out all of what's left of your hair, then try checking the \bin folder. Like most proj files might have several configurations grouped under the XML element PropertyGroup, then I changed the OutputPath value from 'bin\Debug' to remove the '\Debug' part and Rebuild. This placed the files in the \bin folder allowing the Express IIS to find and load the build. I am left wondering what is the correct way to manage these different builds so that a local debug deploy is able to find and load the target environment.
I also got the same error...check the name of the Application you developed properly ie. the namespace and the assembly name alloted and also try physically changing the name of the folder created for the application, all of this should be same as the name in the above namespace present in the file global.asax
I also got the same error...check the IIS Configuration of your Virtual Directory and be sure that Properties - ASP.NET - ASP.NET Version is the same of Project Properties - Application - Target Framework. (That fixed this error for me.)
My app was built in an older version of VS, and didn't have a bin folder. I had upgraded it to a newer version, and had a nightmare getting it to deploy. I finally tracked this error down to the Project > Properties > Application. The Target Framework was set to 2.0; changing it on the server to match in the IIS Manager/App Pool solved the issue for me.
I found that changing the Namespace on the project, without refactoring that across the whole solution was my problem. Check your project Properties and see what your namespace is, ensure that lines up, across the board.
The problem for me is that I didn't include global.asax.cs in my project. And because I was copying files from a .net 4.5 to a 4.0 I didn't comment out lines that are not needed in 4.0. Because it was not included visual studio compiled it anyway without issues. But when I included it, it highlighted the lines that cause problems.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//using System.Web.Http;
using System.Web.Mvc;
//using System.Web.Optimization;
using System.Web.Routing;
namespace YourNameSpace
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
//GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
//BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
I spent literally a day trying to resolve this.
The only thing that worked was deleting the .sln file, creating a new one, and adding the projects back in one by one.
¯\_(ツ)_/¯ - Programming - ¯\_(ツ)_/¯
For my case, the web assembly was part of GAC... so after build, it need to installed in GAC and it worked.
I encountered this error message and eventually discovered that the error message was misleading. In my case there appears to have been a routing issue in IIS which caused the global.asax from another site on the web server to be read thus generating the error.
In IIS, my site was bound to http:*80:webservices.local and contained an application called MyAPI. I received the dreaded message when calling the MyAPI application using the web server's ip address.
In order to successfully call my application I had to add a host file entry for webservices.local on all of the machines that called the MyAPI application. Then all of my requests had to be prefixed with http://webservices.local/MyAPI/ in order to route correctly.
I tried absolutely everything here and nothing worked. My project was in VS 2013. I have since upgraded to VS 2015 and have been creating all of my new applications in 2015 but loading, compiling, building etc all of my old apps that were built in 2013 in that version.
I ended up just loading the solution in 2015 and it resolved it for me.

Setting up SubSonic with Databases other than SQL Server

I am currently using SubSonic (2.2 and 3) for some ASP.NET projects and have managed to get them working with SQL Server (using ActiveRecord). However, I also want to know how to set it up with other (open source) databases, e.g. PostgreSQL and SQLite. This is so I can use it on a web host without SQL Server on. The providers I have found are:
PostgreSQL: Npgsql
SQLite: System.Data.SQLite or Mono.Data.SqliteClient (if it works with Microsoft.NET)
Anyone have any experience with SubSonic know how to do this (some sample demo would be good - just a basic primer on querying would be fine)? Non-ASP.NET MVC though (not got into it yet). I have only basic knowledge of SQLite (basically using SQLite Manager in Firefox and querying it via PHP Data Objects) and have not used Postgresql, but assume it would be more scalable than SQLite.
For version 3
PostgreSQL: There aren't any templates for postgres at the moment so you'd need to create the templates yourself
SQLite - The steps should be as follows:
Add a reference to System.Data.SQLite
Look in the TemplateProviders folder you'll find a SQLite.ttinclude which you'll need to drop into your project instead of SQLServer.ttinclude.
Change the .tt files that reference SQLServer.ttinclude to reference SQLite.ttinclude instead.
This is so I can use it on a web host without SQL Server on.
With the release of SQLExpress dont all hosts offer this? (I only use dedicated server so I have no direct experiance with this)
In response to your question.
SQLite - http://codefornothing.wordpress.com/2007/07/19/sqlite-data-provider-for-subsonic-part-2/
Postgre: Doesnt look as simple,
Subsonic postgreSQL Template
PostgreSQL via subsonic
Good luck.
In short, Subsonic only support few database only NOT ALL ( that what their claimed :( ). Try nHibernate, support most of the database.

Resources