SubSonic3 Context.cs Issue - subsonic

I have an issue when the Context.cs is generated.
I have followed the SubSonic3 setup for ActiveRecord, http://www.subsonicproject.com/docs/Using_ActiveRecord. I am using the AdeventureWorks sample database provided by MS.
This is one of many lines having the issue:
DataProvider.Schema.Tables.Add(new StoreTable(DataProvider));
This is the error I am receiving for all tables in the database:
The type or namespace name 'StoreTable' could not be found (are you missing a using directive or an assembly reference?)
I would appreciate any help resolving this issue.

Hey Rich - make sure you use the "Structs.tt" file as well - I need to update the docs. The Structs generate the schema stuff you need.

Related

RazorEngine and Visual Studio 2015 IntelliSense

This post is not about ASP.NET MVC.
I am using RazorEngine for template processing available here:
https://antaris.github.io/RazorEngine/
The documentation states that I can have IntelliSense if I follow the instructions below:
https://antaris.github.io/RazorEngine/IntellisenseAndResharper.html
However, VS shows the following error:
The type or namespace name 'RazorEngine' could not be found (are you
missing a using directive or an assembly reference?)
Also the following errors:
The type or namespace name 'Linq' does not exist in the namespace
'System'
The type or namespace name 'Helpers' does not exist in the namespace
'System.Web'
The type or namespace name 'WebPages' does not exist in the namespace
'System.Web'
The type or namespace name 'WebPages' does not exist in the namespace
'System.Web'
The type or namespace name 'WebPages' does not exist in the namespace
'System.Web'
Am I getting the errors because I am editing the .cshtml in a command line project where the instruction assumes I use the web project? That doesn't make sense since RazorEngine does not have any project type requirement.
How can I address the issue? How can I edit .cshtml files in a command line project with IntelliSense without all of the above errors?
Found the answer
RTFM
According to the web page:
Your project output path is set to bin\ instead of bin\Debug\ and bin\Release.
another possible solution is to copy RazorEngine.dll and System.Web.Razor.dll to bin.
I am not deleting the post since it might help others.
Found the answer
RTFM
According to the web page:
Your project output path is set to bin\ instead of bin\Debug\ and bin\Release. another possible solution is to copy RazorEngine.dll and System.Web.Razor.dll to bin.

T4 Template Processing Error: "Failed to resolve type for directive processor <directive processor name>."

So I've been having this really nasty error that I've been trying to get rid of for the past couple of days...
I have a T4 template that I run in the debugging solution of a Domain Specific Language (DSL) that I'm building (let's assume it's called MyDsl :P). I have this as the template header:
<## template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>
<## output extension=".txt" #>
<## MyDsl processor="MyDslDirectiveProcessor" requires="fileName='Sample.mydsl'" #>
The issue is caused by the custom directive, which prevents template generation because it "Failed to resolve type for directive processor MyDslDirectiveProcessor." When I remove the custom directive to try to see if the error depends on something else, I get an error in the first (template) directive, that ModelingTextTransformation does not exist in the namespace Microsoft.VisualStudio.TextTemplating.VSHost.
This also happens with the automatically-added templates in this debugging solution, since they contain these same code lines.
Help is appreciated :)
P.S: I use Visual Studio 2012. Also, possible similar question here.
So apparently I accidentally renamed my project name in DSL Explorer...I was probably naming something else and my computer went stupid on me without me realizing it.

Where did HttpProviders go in IAppHost?

I'm having problems in a project that runs on the v3.9.0.0 version of servicestack.
So I'm trying to download source for it. But on github there are no tags so it seems I cant get hold of the source. So... I downloaded the latest stack and the source for that.
Obviously I'm getting some deprecated warnings but except for that the compiler seems happy enough except for in one place
public virtual void Configure(IAppHost appHost, Container container)
{
appHost.HtmlProviders.Add(new HtmlProvider().ProcessRequest);
The compiler complains that IAppHost does not have a property HtmlProviders
Like so:
ServiceStack.WebHost.Endpoints.IAppHost does not contain a definition for HtmlProviders and no extension method 'HtmlProviders' accepting a first argument of type ServiceStack.WebHost.Endpoints.IAppHost could be found (are you missing a using directive or an assembly reference?)
I can't find anyone mentioning this missing so I'm guessing I'm missing something but what.
So at the end I guess the questions are:
Does anyone know how to get the source for the v3.9.0.0 version of servicestack?
Does anyone know what to do to migrate from v3.9.0.0 to current 3.x version considering the above HtmlProviders problem?
(I edited this post as I misread the version number at first)
Checking history for IAppHost your probably looking for roughly v3.94, about 10 months ago. How to upgrade to latest version? I'd suggest migrating a single service to the new API and going from there.

Error while compiling a library in C#

I am trying to compile a class(sqlAccess) declared as public with few methods related to database connection in it. I am getting the following error ...
Error 1 Friend access was granted to 'SqlAccess, PublicKey=00c8', but the output assembly is named 'SQLAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Try adding a reference to 'SqlAccess, PublicKey=00c8' or changing the output assembly name to match. c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll SQLAccess
What could be the reason? is there already a method of that name? I am new to programming so am unable to understand this clearly. Thank you.
This worked for me:
Open the Properties|Signing Tab. Ensure that you have "Sign the Assembly" checked and the strong name key file referenced. Save and compile the Project/Solution.
(cited from MSDN)
.NET seems to get grumpy if you give your assembly/project a name that isn't unique. In your case, SqlAccess must already exist in .NET or a referenced assembly.
The fix is to rename your assembly.
Similar issue:
Weird error in C#
That's because SqlAccess assembly has a reference which granted internal access to SqlAccess. It must be something like this [you will find it in AssemblyInfo.cs] :
[assembly: InternalsVisibleTo("Name of assembly goes here, PublicKey=")]
During compile time when compiler can not find assembly with specific PublicKey, you will get the error such as 'Friend access was granted to...'.
In order to resolve this problem one solution is to remove above attribute from source assembly, or add new public key and change it in source assembly.
Reason behind this should be either you have reinstall/update that particular dll within your solution and but old dll was not deleted properly from your solution and system.
That's why, it got worked when you change the Assembly name (from sqlAccess to sqlAccessXYZ)
I changed the Assembly name to sqlAccessXYZ and now its working, the problem is with the name. Not sure what exactly the problem, for now the issue is resolved. Thanks.

Compile errors with subsonic 3.0 activerecord?

Note, I have used subsonic 2.2 extensively and love it. This is my first experience with 3.0.
I want to add subsonic to my class library rather than the website. First when I do this, and try and run the custom tool to compile the template files, I get errors saying there is not app.config file. In subsonic 2, I was able to do this and point it to my web.config file. So first question is can I use the web.config file when adding subsonic to an external class library?
The second thing that I'm experiencing are 44 identical compile errors.
This is the error from VS 2008:
Error 44 'krazyCommon.model.atDB' does not contain a definition for 'Provider' and no extension method 'Provider' accepting a first argument of type 'krazyCommon.model.atDB' could be found (are you missing a using directive or an assembly reference?) C:\dev\krazybuys\krazyCommon\model\StoredProcedures.cs 175 100 krazyCommon
and this is the code that is causing it. The end of the line this.Provider is where the error is being caused. In VS it has a squiggly line under it.
public StoredProcedure aspnet_UsersInRoles_RemoveUsersFromRoles(){
StoredProcedure sp=new StoredProcedure("aspnet_UsersInRoles_RemoveUsersFromRoles",this.Provider);
return sp;
}
I'm perplexed as I think I'm doing everything correct. Any help would be appreciated.
Many Thanks.
Update, I did find the cause of the compile error. I changed the namespace in the settings file. However, the namespace did not update in the storedprocedure.tt output. It does change for activerecord and content, but not storedprocedures. I manually changed the namespace and it compiled without error.
Is this a bug in the template or subsonic?
Is it possible to change the namespace in settings? And if so, should subsonic pick that up if you right click on activerecord, content and storedprocedures and "Run custom tool" again.
Thanks
Sorry I forgot to add that I did add an app.config file to the class library and added a conn string before I got the 44 errors.

Resources