RazorEngine and Visual Studio 2015 IntelliSense - razorengine

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.

Related

How to use tlb files in a native C++ project

I have a tlb files that contains some function declaration that I need to use.
If I use
#import "type_library.tlb"
I can correclty reference the function from my code:
tlb_namespace::required_function();
But when I compile the project the linker says that tlb_namespace::required_function is an unresolved external symbol.
How can I succesfully build this kind of project?
EDIT:
I have used the same type library in a Dummy VBA access project. I have added the reference to the type library and I have noticed that some of the function contained in the type library are correctly called. But some of them are not. VBA says It can't locate their entry point in the related dll.
Can this explain the unresolved external symbol when building c++ app?
I have also noticed that the failing function are declared in the tlb like this:
UPPER_function_name
but in the dll are declared like this:
Upper_function_name
Can this be the issue?
Is it possible to solve this kind of error directly modifying the binary tlb file or dll?
Use IDE to view TLB information.
Use this help : How to: View Type Library Information
At IDE : View-> Object Browser, click "..." Edit Custom Component Set, browse your TLB file and Add to view information.
Confirm namespace used for.
use the namespace to resolve the linker error:
example:
#import "<>" raw_interfaces_only
using namespace <>
this will resolve the problem

How to tell the parser where to look for a local copy of xml.xsd?

I am creating an eclipse rcp application in which I am using SAXParser to parse an XML document. The "EventsDefinition.xsd" which I am using to validate the XML document has following import:
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml.xsd"/>
I keep the "EventsDefinition.xsd" & "xml.xsd" in the eclipse folder of the exported rcp product.
For accessing the "EventsDefinition.xsd", I use the following code which works.
URL fileURL = new URL(Platform.getInstallLocation().getURL() + "EventsDefinition.xsd");
File eventsDefinitionFile = new File(fileURL.getPath());
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", eventsDefinitionFile);
With this, the parser is able to access "EventsDefinition.xsd" but not the "xml.xsd" referenced by it, because it tries to find the xml.xsd relative to the directory from which the rcp application is executed.
Is there a similar way to tell the parser to find the "xml.xsd" at eclipse folder rather than in the present working directory?
I tried specifying schemaLocation="http://www.w3.org/2001/xml.xsd" in EventsDefinition.xsd, but it fails to read the schema. So I have to use the local copy of "xml.xsd" present at the exported product's eclipse folder.
Any suggestions will be extremely helpful.
I think that the problem is with the import declaration. First, although permitted, is not recommended to use "namespace" as a namespace prefix. Second, the problem arises form the fact that you use "http://www.w3.org/XML/1998/namespace" as namespace name, which is prohibited. Take a look here: http://www.w3.org/TR/REC-xml-names/#dt-prefix , precisely here:
The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace.
Try to rename the namespace name to something else (and the namespace prefix too). Hope it helps.

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.

"MSXML2" has no member "IXMLDOMNode" problem in VC++ 2010

I'm trying to compile a VC++ project I've inherited that uses MSXML2. This is an ATL .EXE project. A header file includes the following:
#include "msxml2.h"
using namespace MSXML2;
Preprocessor definitions include __USE_MSXML2_NAMESPACE__, which I added to the project because without it the MSXML2 namespace was undefined. Attempting to build this project I receive many errors of the form:
error C2039: 'IXMLDOMNode' : is not a member of 'MSXML2'
These errors are produced by declarations like the following
CComPtr<MSXML2::IXMLDOMNode> pNode;
Other members are not found, including IXMLDOMDocument and IXMLDOMNode.
You can fix this
Include msxml2.h header.
Remove USE_MSXML2_NAMESPACE and using namespace MSXML2 code.
Use CComPtr<IXMLDOMNode> pNode; without namespace.
I've seen many projects using import keyword to ask Visual C++ to generate the header file from TBL using MSXML2 namespace. However, using header and linking to lib is my favorite way to avoid using import keyword as it is not c++ standard. The bottom line is to avoid mixing the two approaches when refreshing old projects, which will lead to problems like this.

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