list problem in c#. how to do this in c# - 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.

Related

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.

MediaWiki invoke image not working

I'm trying to invoke an image with infobox and infoboxImage. Here is what I have....
|image = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}|size={{{image_size|}}}|upright= {{{image_upright|1}}}|alt={{{alt|}}}}}
And I get the following error on my index.php?title=Module:InfoboxImage&action=submit#mw-ce-l1 page
Script error: Lua error at line 1: unexpected symbol near '|'.
What do I need to do to get this working?
Here is my LocalSettings.php for Scribunto:
require_once "$IP/extensions/Scribunto/Scribunto.php";
#$wgScribuntoDefaultEngine = "luastandalon"';
So you're adding template syntax like {{{image|}}} in a module page? Why?
I doubt you really need to handle such a Lua module for your wiki. However, if you really want to copy the Lua-powered infobox templates of other wikis, make sure you import them with Special:Import and select the recursive import checkbox.
Hopefully you'll then have all the modules you need without fiddling with them.

WebMatrix Session variables not working

due to an oversight on my part (still new to AppState and Session variables) I have to change all of my AppStates to Session variables. WebMatrix's replace has made that part easy, however I am now getting this error on the first of the two lines of code below:
Session["gActionMessage"] = "";
Session["gActionMessageDisplayed"] = "not";
Error:
Compiler Error Message: CS0103: The name 'Session' does not exist in the current context
If it matters, these lines of code are in my _AppStart.cshtml file.
Any suggestions? Do I have the syntax wrong?
Sessions are not available at the point that the _AppStart.cshtml file is executed. That happens too early in the pipeline. You can use _PageStart.cshtml to initialise session variables.

Google Calendar In Asp.net C#

I want to make event calendar in my web application.
I use this example but it return error wheni i execute it.
http://www.codeproject.com/Articles/201907/Using-Google-Calendar-in-an-ASP-NET-Website
ERROR IS GIVEN BELOW
-----------------------------------------------------------------------------------
Compiler Error Message: CS0103: The name 'GetCalendarID' does not exist in the current context
Source Error:
Line 11: <div>
Line 12:
Line 13: <iframe name="a" src="https://www.Google.com/calendar/embed?src=<%=GetCalendarID()%>&ctz=Europe%2FMoscow"
Line 14: style="border: 0" width="800"
Line 15: height="600" frameborder="0" scrolling="no" id="Test">
-----------------------------------------------------------------------------------
Can any one help me Please?
or if you have better solving then tell me
Regards,
Mehmood Alvi
You're trying to call GetCalendarID() (which would more idiomatically be a property, of course) directly from your page - not on an instance of the GoogleCalendar class. Unless you've added all the GoogleCalendar code from CodeProject directly into your page, you need to first create an instance of GoogleCalendar in your code-behind and provide some way of accessing it, e.g. as a member variable:
<%=calendar.GetCalendarID()%>
Fundamentally, the problem is as simple as the compiler's explained it to be: it can't find a method called GetCalendarID in the context it's got, which is the page. The exact best solution will depend on what else you're doing - the above is just an idea.
You should first call the method SaveCalendarIdAndUrl() cause thats where the m_CalendarId; gets filled before it can be used by the method GetCalendarID()

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.

Categories