resx

How to use a resx resource file in a T4 template

为君一笑 提交于 2019-12-03 20:31:39
问题 I cant figure out how to include the resource file (.resx) in the (.tt) T4 template. I tried so far... Importing the namespace <#@ import namespace="T4TemplateResources.resx" #> Also including the class 回答1: Nico's solution requires your solution to build. There is another way, without needing to compile your solution by reading the raw resx file. var fileName = "CustomResource.resx"; var filePath = Path.Combine(Path.GetDirectoryName(this.Host.ResolvePath("")), "WindowsFormsApplication1",

Is it possible to use a variable for the `[Display(Name=“Something”)]` data annotation in MVC3 (C#)

孤街醉人 提交于 2019-12-03 16:42:09
not sure why, but the data annotation in MVC3 insist on having constant values, which i just can't understand for things like error messages and display names. I love these annotations, they are so easy to use and so powerful, but what if you need to support multiple languages? Imagine i have the following model: public class Person { public string First_Name { get; set; } } If i dont change anything and use the CRUD views that MVC3 will build for me I get a label next to the text fields that says "First_Name", so i add the data annotation to change the display name like so: public class

MissingManifestResourceException on Windows Phone 8.1 with .resx resources

元气小坏坏 提交于 2019-12-03 15:52:17
问题 I'm developing a Windows Phone 8.1 app that also targets Android(Xamarin) As ever I added my string resources(.resx) on a PCL and referenced them on my launcher project to use it on my views, this all works fine on WP 8.1 silverlight but on the WinRt when I configure the project to release and run it on a device, for some reason I always get a MissingManifestResourceException. I've tried every solution for this problem out there without any success. Note that on the emulator everything works

Performance Overheads when Using Resource Files (.resx)

﹥>﹥吖頭↗ 提交于 2019-12-03 10:55:07
Note, I am aware of the following questions on this topic: Are there any performance issues or caveats with resource (.resx) files? Are string resources (.resx) properties kept in memory? et al. However, I don't find any of the answers in these questions satisfactory (they are not concrete enough). I am also aware of the MSDN pages on this topic, but these also seem to skimp on the technical information regarding the overheads of using resource files. My predicament is that we are about to embark on the localisation of a reasonably large sized WinForms application. My concern at this stage is

MissingManifestResourceException on Windows Phone 8.1 with .resx resources

给你一囗甜甜゛ 提交于 2019-12-03 05:21:30
I'm developing a Windows Phone 8.1 app that also targets Android(Xamarin) As ever I added my string resources(.resx) on a PCL and referenced them on my launcher project to use it on my views, this all works fine on WP 8.1 silverlight but on the WinRt when I configure the project to release and run it on a device, for some reason I always get a MissingManifestResourceException. I've tried every solution for this problem out there without any success. Note that on the emulator everything works fine, when the solution configurator is set to Debug it also works on both device and emulator. The

Changing Resource files (resx) namespace and access modifier

亡梦爱人 提交于 2019-12-03 04:04:25
问题 In my webproject I'm using 4 resources files in my App_GlobalResources folder. One of them ( lang.resx ) has been created before my arrival on the project. It has the correct namespace ( WebApplication.App_GlobalResources ) and access modifier : public . On the other hand, the three others Resource files that I just created have a different namespace ( Resources ) and internal access modifier, and I can't change it on the Resource File Form from Visual Studio because it's disabled. If I try

How to avoid unnecessary changes in *.designer.cs and *.resx?

情到浓时终转凉″ 提交于 2019-12-03 02:34:05
For some reason Visual Studio winforms designer time to time applies dull changes to form designer files and respective resx. Most annoying so far: changes to order of controls declarations/initialization changes to some control sizes (most notably menu items widths) changes to serialized images embedded into resources (...wait, what???) Those changes doesn't affect form/user control functionality or it look, but they create lot of noise in source control, making merges almost impossible, or require error prone manual fixing to eliminate all changes that actually change noting, just until next

Referencing resource files from multiple projects in a solution

坚强是说给别人听的谎言 提交于 2019-12-03 00:23:10
I am working on localization for a asp.net application that consists of several projects. For this, there are some strings that are used in several of these projects. Naturally, I would prefer to have only one copy of the resource file in each project. Since the resource files don't have an namespace (at least as far as I can tell), they can't be accessed like regular classes. Is there any way to reference resx files in another project, within the same solution? You can just create a class library project, add a resource file there, and then refer to that assembly for common resources. I have

Changing Resource files (resx) namespace and access modifier

为君一笑 提交于 2019-12-02 17:23:42
In my webproject I'm using 4 resources files in my App_GlobalResources folder. One of them ( lang.resx ) has been created before my arrival on the project. It has the correct namespace ( WebApplication.App_GlobalResources ) and access modifier : public . On the other hand, the three others Resource files that I just created have a different namespace ( Resources ) and internal access modifier, and I can't change it on the Resource File Form from Visual Studio because it's disabled. If I try to change it directly in the designer.cs file, the modifications are cancelled on the next save of the

Store Image in .resx as byte[] rather than Bitmap

≡放荡痞女 提交于 2019-12-01 20:50:50
Slightly daft, but... Is there a way to prevent Visual Studio treating a .jpg file in a .resx as a Bitmap so that I can access a byte[] property for the resource instead? I just want: byte[] myImage = My.Resources.MyImage; Try using an "Embedded Resource" instead So lets say you have a jpg "Foo.jpg" in ClassLibrary1. Set the "Build Action" to "Embedded Resource". Then use this code to get the bytes byte[] GetBytes() { var assembly = GetType().Assembly; using (var stream = assembly.GetManifestResourceStream("ClassLibrary1.Foo.jpg")) { var buffer = new byte[stream.Length]; stream.Read(buffer, 0,