Cannot access key in resource file from mvc 4 controller - asp.net-mvc-4

I have a resource file called Constants.resx which contains some strings. From the controller I am trying to access to a new string that I have just added to Constants.resx file but it is not recognized by the compiler (intellisense is not showning me the new string just added) and of course when I type it, an error is shown.
In the controller header I have added below line:
using Resources;
and to access to the new string just added I do the following:
Resources.Constants.NewString
I access to other strings in Constants.resx file using the same approach and no problem, they are recognized correctly, but not this new one.
Any ideas?
UPDATED:
My resource file for my mvc 4 app was added by selecting "Add > new item" from App_GlobalResources context menu and finally selecting "Resource file".
My resource files properties are:
Build action: Content
Copy to Output Directory: Do not copy
Custom Tool: GlobalResourceProxyGenerator
Custom Tool Namespace: (left blank)
Also I am using Visual Studio 2010 Express edition.
I can see the compiler is throwing a warning saying it cannot find the custom Tool 'GlobalResourceProxyGenerator' in the system.

You have to set the namespace of all the resource files as a common namespace like ViewResource. Then change the access modifier in the resource file as public. Now you can access those resource files.
Build action: Content
Copy to Output Directory: Do not copy
Custom Tool: GlobalResourceProxyGenerator
Custom Tool Namespace: ViewResource
Access Modifier : Public (In all resource Files)

Related

IntelliJ not recognizing typescript named module declarations

I have a situation where my module names need to be in a certain format. Typescript is fine when I do this:
// knockout interfaces, this is knockout.d.ts
declare var ko: KnockoutStatic;
declare module "core!lib/knockout" {
export = ko;
}
And then in my file that uses it:
import ko = require('core!lib/knockout');
IntelliJ doesn't like it though. It says "cannot find external module 'core!lib/knockout'. I'm using the latest stable version (14.1) and this happens with the in-built 1.4 compiler and a custom one.
I guess this may be a Jetbrains bug?
If you add this to the file with the import statement the error will probably go away
/// <reference path="test.ts" />
The real problem I think is that the configuration isn't fully correct. Is the config root correct or are you maybe using version control?
Relevant bits from the link:
From the Scope drop-down list, choose the scope to apply the compiler in. The available options are: – Project Files: all the files within the project content roots (see Content Root and Configuring Content Roots).
– Project Production Files: all the files within the project content roots excluding test sources.
– Project Test Files: all the files within the project test source roots.
– Open Files: all the files that are currently opened in the editor.
VCS Scopes: these scopes are only available if your project is under version control.
– Changed Files: all changed files, that is, all files associated with all existing changelists.
– Default: all the files associated with the changelist
See https://www.jetbrains.com/idea/help/transpiling-typescript-to-javascript.html

can't find a reference for LinqDataSource used in designer

When converting a website to a web app, the designer creates the code
protected global::System.Web.UI.WebControls.LinqDataSource
and I get the error
namespace name 'LinqDataSource' does not exist in the namespace
'System.Web.UI.WebControls'
when I try to compile.
I tried creating a new project, making sure LinqDataSource was working by adding it from the toolbox to a webpage.
After copying my existing project into the solution as a folder it failed, turns out it doesn't like the bin folder from my previous project in a subfolder of the new project.

Read Global resource file inside controller

How can I read global resource file in MVC controller, I am using this code and it is not working
Resources.BillingResource.Error;
returns the following exception
Could not load file or assembly 'Resources' or one of its dependencies. The system cannot find the file specified.
My application is MVC 4 and framework 4.5
Please advice
Is the resource file loaded in the same project or is on the different project. If its different project , you would have to add the reference to it.
Also check the namespace generated by the cs file of the resource file and reference that in your view or controller.

How to Generate a proxy class in a specific project by using svcutil.exe?

By default svcutil.exe generates proxy class and its .config in C:\Program Files\Microsoft Visual Studio 9.0\VC.
What is syntax for generating a proxy class in a specific project by using svcutil.exe ?
Use the /directory option.
To quote directly from the help which is displayed when you type svcutil /? :
/directory:<directory> - Directory to create files in (default: current directory) (Short Form: /d)
Just to elaborate a little more... svcutil just generates the files, it doesn't manipulate the .proj file to add a file to the project, you have to do that yourself. What you might want to do is:
show all files in the Solution Explorer, then refresh the folder containing the generated files, then select them all and add them to the project (you should remove the existing files before doing a manual generation)
write a little batch script or command line app that iterates the folder the files are created in and inserts entries for them into the .proj file.
if possible use the Add Service Reference option from the context menu in the Solution Explorer, that generates the files and adds them to the project for you

adding jpegs to vb.net application

i am using itextsharp and creating a PDF with images.
currently the images i am using in the application are on my desktop, but i will need to make an installation file that will put the images in a specified directory on the users computer and be able to call them from the specific directory.
how do i include pictures with my build?
how do i reference the pictures? currently i am using:
Dim jpeg3 As Image = Image.GetInstance(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\2.jpg")
How and where do you add the pictures?
If you simply added them to the project as if they were code files (using "add existing item"), then check the Properties for the file in the solution explorer (Build Action, and Copy To Output Directory are useful), and also the Application Files button/window (under the project settings -> Publish). This is useful for distributing the files along with the application (for both debug and release), deployed in a specific sub-directory.
If you added the files to the project's resource file, you can use them using the My.Resources namespace.