Cassette.AssetReferenceException being fired when removing a file from folder - c#

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.

Related

DNN Upgrade 7 to 8 Error (DotNetNuke.UI.WebControls.SolPartActions)

when i upgrade the my dnn web site its give the following error
Could Not Load Container: /Portals/_default/Containers/20067-UnlimitedColorsPack-049/No Title.ascx
DotNetNuke.Services.Exceptions.ModuleLoadException: Unhandled error loading module.
---> System.Web.HttpParseException: Could not load type 'DotNetNuke.UI.WebControls.SolPartActions'.
---> System.Web.HttpParseException: Could not load type 'DotNetNuke.UI.WebControls.SolPartActions'.
---> System.Web.HttpException: Could not load type 'DotNetNuke.UI.WebControls.SolPartActions'.
at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)
at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)
at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace
--- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
In DNN 8 Removed the Solpart so this causes raise .
please remove the following line in your Container file.
<%# Register TagPrefix="dnn" TagName="ACTIONS" Src="~/Admin/Containers/SolPartActions.ascx" %>
<dnn:ACTIONS runat="server" id="dnnACTIONS" />
For more information about DNN Release click here
Looking at the error I assume the site itself does work, only that the correct Container is not loaded.
For some reason DNN can't find the Container No Title.ascx located in /Portals/_default/Containers/20067-UnlimitedColorsPack-049/. Manually check if it is still there and if the folder is accessible for IIS and the AppPool.
If not you can do 3 things:
Create that folder again and copy a Container from another Container
folder to that one and give it the same name.
Select a different default Container under "Site Settings >
Appearance".
Reinstall the Container pack under "Host > Extensions"
If one of there does not solve your problem then there is something else going on and we'll have to look further.
The key here is that the SolPart menu has been removed in DNN8. Either of the answers you've received will work. The first one, to remove references to SolPart from the container files should be fine, and not change behavior if the containers provide decoration that you want/need.
Might be a good time to revisit your skin/theme, as it's clearly an old one.

How to use c# singleton class in Orchard Themes

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.

Code Contract : ccrewrite exited with code -1?

I'm new to code contracts. I downloaded the latest build of code contract project (1.4.40314.1) and started to implement it in my project. When i enabled 'Runtume Checking' through Code Contracts Tab in VS2010, i got this Error
Error 1 The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "#Application1ccrewrite.rsp"" exited with code -1.
everytime i build the project. Plz help.
Now it's a major problem for me.
Every project using code contracts is showing same error in VS2010 Errors window and 'Application1ccrewrite.rsp' not found in output window, but it is there.
I tried out everything. I installed both versions (Pro, Std) but the problem persist. Plz help !
I had this problem as well. In my case the problem was that ccrewrite cannot work with files in a network folder but requires the project to be on your local hard disk.
I had this problem. The Assembly name and Default namespace of the class library that causes the problem had the same name as an existing DLL in the destination folder. I had been refactoring my code and whilst the namespaces in the CS files had all be changed to namespace2 the default namespace in the properties file was still namespace1
When I corrected this the files all built successfully...
Sometimes you can get this when your solution path is too long, especially with many projects.
Try moving to c:\temp and building it, it might fix it (although of course, this might not be a solution if you need it in the folder it currently is).
This bug I noticed in earlier CC versions and may now be fixed.
I don't know if you had the same problem as me, but I also saw this error. In my case, I had a method with a switch statement, and depending on the branch taken, different requirements applied:
static ITransaction CreateTransaction(
String transType,
MyType1 parm1,
/* Other params unimportant to this example */
String parm5)
{
switch (transType) {
case Transaction.Type.SOME_TRANSFER:
Contract.Requires<ArgumentNullException>(parm1.Account != null, "Account cannot be null.");
Contract.Requires<ArgumentException>(!String.IsNullOrWhiteSpace(parm5), "parm5 cannot be null or empty.");
// Create instance
return someInst;
case Transaction.Type.SOME_OTHER_TRANSFER:
Contract.Requires<ArgumentException>(!String.IsNullOrWhiteSpace(parm1.Type), "Type cannot be null or empty.");
Contract.Requires<ArgumentException>(!String.IsNullOrWhiteSpace(parm1.Number), "Number cannot be null or empty.");
// Create instance
return someInst;
/* Other cases */
default:
throw new ApplicationException("Invalid or unknown transaction type provided.");
}
}
This was giving me the error you noted in the Errors List when I tried to build. In the output window, I was getting this:
EXEC : Reference Assembly Generator
warning : Something is wrong with
contract number 1 in the method
'TerraCognita.LoanExpress.Domain.Loan.CreateLoanTransaction'
AsmMeta failed with uncaught
exception: Operation is not valid due
to the current state of the object.
I pushed each branch into a method of its own, making Contract.Requires the first lines of code in each method, and I no longer had a compilation problem. It appears that Contract.Requires must be the first lines of code in a method - which makes sense, since they are intended to be used to define pre-conditions.
Hope this helps.
The solution is to put the pre and pos conditions in the first lines. The ccrewrite does not accept that pre and post conditions are below command lines.

list problem in c#. how to do this in c#

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.

How to create resource manager in ASP.NET

I would like to create resource manager on my page and use some data stored in my resource files. (default.aspx.resx and default.aspx.en.resx)
The code looks like this:
System.Resources.ResourceManager myResourceManager = System.Resources.ResourceManager.CreateFileBasedResourceManager("resource",
Server.MapPath("App_LocalResources") + Path.DirectorySeparatorChar, null);
if (User.Identity.IsAuthenticated)
{
Welcome.Text = myResourceManager.GetString("LoggedInWelcomeText");
}
else
{
Welcome.Text = myResourceManager.GetString("LoggedOutWelcomeText");
}
but when i compile and run it on my local server i get this type of error:
Could not find any resources appropriate for the specified culture (or the neutral culture) on disk.
baseName: resource locationInfo: fileName: resource.resources
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.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture (or the neutral culture) on disk.
baseName: resource locationInfo: fileName: resource.resources
Source Error:
Line 89: else
Line 90: {
Line 91: Welcome.Text = myResourceManager.GetString("LoggedOutWelcomeText");
Line 92: }
Line 93:
can you please assist me with this issue?
Use GetLocalResourceObject() which is part of a System.Web.Page's base.
If you wish to access global resources use GetGlobalResourceObject().
keep it simple ;-)
According to MSDN, CreateFileBasedResourceManager is expecting compiled resource files. Usually, one puts .resx files in App_LocalResources. Do you have files in this directory named resource.XXX.resources (where XXX is the current culture id) in this directory.
I don't have a VS handy in order to check this in an ASP.NET project, but the usual way to handle resource strings is to go the project properties, Resources tab and create strings there. This generates a strongly-typed wrapper around your resources, avoiding the need to explicitly create your own ResourceManager.

Categories