I'm using Orchard to build my website and want to add different elements for production environment and test environemnt in the Themes. I tried to use a c# singleton class in Orchard Themes class to get if it is production environment. Then use the singleton class in the cshtml file in Themes. The code can be compiled. But in run time, it will throw exception saying:The name 'Themes' does not exist in the current context. I have to add "Themes" namespace before the class I added. Otherwise, it won't pass compile.
Details:
I added a singleton class: EnvironmentDev.cs file into Themes.csproj file. It contains static GetInstance method and IsProd property.
In Themes.csproj file, it shows:
<ItemGroup>
<Compile Include="EnvironmentDev.cs" />
</ItemGroup>
In Document.cshtml file of Themes, I added following code:
#{
if (Themes.EnvironmentDev.GetInstance().IsProd) {
// Add production element
}
else {
// Add test site element
}
}
Detailed Error message:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Themes' does not exist in the current context
Source Error:
Line 46: #Display(Model.Head)
Line 47: #{
Line 48: if (Themes.EnvironmentDev.GetInstance().IsProd) {
Line 49: <script src="https://XXXX.js"></script> //using XXXX instead of real link
Line 50: }
Any suggestions would be appreciated.
I think you need to create a dedicated project for your theme with the following command
codegen theme MyTheme /CreateProject:true /IncludeInSolution:true
otherwise your code will not be found. I had the same issue with a resource file.
See paragraph Generating the Theme Structure in the docs for further information.
Related
MvvmCross.Plugin.Location.Fused
Trying to get all the Mvvmcross plug-in work in my demo project.
The sample project come from here
https://github.com/MvvmCross/MvvmCross-Samples/tree/master/XPlatformMenus
Once I have add it from nuget
MvvmCross.Plugin.Location.Fused
Severity Code Description Project File Line Suppression State
Error CS0305
Using the generic type 'MvxPluginBootstrapAction' requires 1 type arguments
XPlatformMenus.Droid
There isn't much docs for the all those plugin .
Hopefully I can get it up and running and see what it really can do.
It needs to be MvxLoaderPluginBootstrapAction instead of MvxPluginBootstrapAction
public class LocationPluginBootstrap
: MvxLoaderPluginBootstrapAction<MvvmCross.Plugins.Location.PluginLoader, MvvmCross.Plugins.Location.Fused.Droid.Plugin>
{
}
This has been fixed, but is not released, yet: https://github.com/MvvmCross/MvvmCross-Plugins/commit/1ff418ca2af0ede8113b6478000522b7631d1030
I am currently saving my .NET FX 4.0.1 StateMachine activity like this:
var sb = new StringBuilder();
var xamlWriter = ActivityXamlServices.CreateBuilderWriter(
new XamlXmlWriter(new StringWriter(sb),
new XamlSchemaContext()));
XamlServices.Save(xamlWriter, activityBuilder);
return sb.ToString();
This works fine and the generated XAML looks good. Unfortunately, it is invalid. I can read it back in using ActivityXamlServices.Load but when I execute it, it says that it doesn't know the properties defined in the workflow. Opening it in the Visual Studio designer yields the same errors:
Compiler error(s) encountered processing expression "ActiveCall". "ActiveCall" is not declared. It may be inaccessible due to its protection level.
Through comparing the original XAML with the XAML produced by my code, I found out how to fix this problem. I have to have this tag before the StateMachine tag:
<mva:VisualBasic.Settings>
Assembly references and imported namespaces for internal implementation
</mva:VisualBasic.Settings>
By the way:
The text inside the tag must be exactly like this, otherwise there will be an error when opening the WF in VS:
Failed to create a 'Settings' from the text 'FooBar'
Question:
What do I have to change in my code to have this tag in the generated XAML?
I think I found the answer.
I have to use the following code before calling Save:
VisualBasic.SetSettings(activityBuilder, new VisualBasicSettings());
If the activityBuilder has been created from a DynamicActivity it is even better to use the following code:
VisualBasic.SetSettings(activityBuilder,
VisualBasic.GetSettings(dynamicActivity));
If this is not used, namespaces that are only needed for extension methods are not written to the XAML and will lead to an error when loading and executing the XAML.
I summarized my findings on code project.
I used to have a .js file in /Public/javascripts/jquery1.1js.
Everything was working perfectly but then I needed to delete this file from my project, so I just removed it from the solution in Visual Studio.
Now when I visit my application, I get:
Reference error in "~/Public/javascripts/jquery.unobtrusive-ajax.js",
line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js". Reference
error in "~/Public/javascripts/jquery.validate.unobtrusive.js", line
1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".
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: Cassette.AssetReferenceException: Reference error
in "~/Public/javascripts/jquery.unobtrusive-ajax.js", line 1. Cannot
find "~/Public/javascripts/jquery-1.5.1.js". Reference error in
"~/Public/javascripts/jquery.validate.unobtrusive.js", line 1. Cannot
find "~/Public/javascripts/jquery-1.5.1.js".
Here's a stacktrace:
[AssetReferenceException: Reference error in "~/Public/javascripts/jquery.unobtrusive-ajax.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".
Reference error in "~/Public/javascripts/jquery.validate.unobtrusive.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".]
Cassette.BundleContainer.ValidateAssetReferences() +387
Cassette.BundleContainer..ctor(IEnumerable`1 bundles) +41
Granted, I know why this is happening, Cassette is still trying to find the deleted file, but I'm not sure how to tell Cassette: "Hey, this file is no longer relevant. Scan the folder again and rebuild a list of files you need to work with."
But I just don't know how to accomplish this.
The documentation has no mention of this and just implies that it should do this automatically for me.
Here's my Configuration class:
using Cassette.Configuration;
using Cassette.Scripts;
using Cassette.Stylesheets;
namespace XXX.WebUI
{
/// <summary>
/// Configures the Cassette asset modules for the web application.
/// </summary>
public class CassetteConfiguration : ICassetteConfiguration
{
public void Configure(BundleCollection bundles, CassetteSettings settings)
{
bundles.AddPerIndividualFile<ScriptBundle>("Public/javascripts/");
bundles.AddPerIndividualFile<StylesheetBundle>("Public/stylesheets/");
}
}
}
And in my _Layout.cshtml file:
#{
Bundles.Reference("Public/javascripts/site.js");
Bundles.Reference("Public/javascripts/jquery.validate.unobtrusive.js");
Bundles.Reference("Public/stylesheets/site.less");
}
<!DOCTYPE html>
...
<head>
<title>#ViewBag.Title</title>
#Bundles.RenderStylesheets()
...
#Bundles.RenderScripts()
</body>
Does the jquery.validate.unobtrusive.js file contain a JavaScript reference at the top to jquery-1.5.1.js?
The line would look like:
/// <reference path="jquery-1.5.1.js" />
If so, remove that line. Cassette uses those references to determine build order.
ref: http://getcassette.net/documentation/scripts
This can also happen if you reference files with the same root
e.g. easyXDM.js and easyXDM.debug.js
When you reference easyXMD.js it gives the exception and the solution seems to be use a different naming convention that ensures the roots are different such as easyXMDdebug.js.
I ran this simple example from the website and I get the error below when it calls Razor.Parse. How can I fix this???
http://razorengine.codeplex.com/
string template = "Hello #Model.Name! Welcome to Razor!";
string result = Razor.Parse(template, new { Name = "World" });
error CS0234: The type or namespace name 'Markdown' does not exist in the namespace 'ServiceStack' (are you missing an assembly reference?)
Not sure why you've linked to http://razorengine.codeplex.com
The 'ServiceStack' error assumes you want to use the Markdown engine in ServiceStack in which case you should be referencing the RazorEngine.dll that comes with ServiceStack not the one in razorengine.codeplex.com if that's what is done here.
I would imagine one of two things has happened. Either in your configuration file, namespaces have been added within the <razorEngine> configuration section, or the AddNamespace method is being called somewhere to include namespace imports in the compiled template.
The net result, is that namespaces are added to the generated class file, but references are missing. RazorEngine will automatically reference any loaded assemblies in the AppDomain.
i have a list of struct
list who have a detail of stuff.
i need a another string info with this list.
so i wrote many function already who is used in my project
so i make a new list
who called stuffdetailedanother
who have a stuffdetailed stuff
and string info;
but when i send it to page using viewdata then he not worked when i use immediate window everything is fine.
are any another way i use ?
or how to pass him to a control
i pass it by a way
controller > View > Partial view
but it is not worked
i got the error
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1519: Invalid token '(' in class, struct, or interface member declaration
Source Error:
Line 347: #line default
Line 348: #line hidden
Line 349: #__w.Write("\r\n </div>\r\n</div>\r\n");
Line 350: }
Line 351:
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\2114142c\1d077c0d\App_Web_wishproductlist.ascx.89207646.1grmjmuq.0.cs Line: 349
The problem is that you have a syntax error on line 351 of your ASPX file. Take a closer look at it. If you don't understand why it's not compiling, post the code.
The problem is that the following line:
#__w.Write("\r\n </div>\r\n</div>\r\n");
(Line 349 in App_Web_wishproductlist.ascx.cs) contains a syntax error - probably the # symbol.
Without knowing more context its difficult to know what other advice to give, however hopefully this helps make the error a little clearer.