I have an xslt file which I initially added to the "Resources" section of my project through the project properties. Inside of my program I call Resources.MyXsltFile to grab the string and I load it using XslCompiledTransform.Load. My program ran fine initially but after I updated the xslt file I noticed that my Resources.MyXsltFile was still using the original xslt contents and not my updated version. What's the deal?
It turns out that the compiled "Resources.Designer.cs" file that goes along with the 'Resources.resx' for the project does NOT get regenerated when you update one of the resource files. Therefore you have to regenerate the "Resources.Designer.cs" file manually. Here is an article from Marek Grzenkowicz which shows how to regenerate the file by right-clicking on "Resources.resx" and clicking on "Run custom tool". After that I ran my program and it finally used the updated version of my resource file.
Also, if you do not want to use Custom Tool solution, make sure that your resource is using not at "No Code Generate" at the Access Modifier.
Related
In a .net application I need to edit an html template that I put inside a Resource file (resx).
If I edit the file from the filesystem and I build and run my application again the template remains unaffected. Even if I edit by opening it from the visual studio Resource visualizer.
The only solution I found so far is by deleting the resource from the template and add it again, also with the same name.
Is there a quicker way to mark the file as modified for the compiler to return the newer version without having to delete and recreate it?
To do this, right-click on the resource file in Solution Explorer and select "Properties".
In the Properties window, locate the "Custom Tool" property and change its value to "ResXFileCodeGenerator".
Then save the change and rebuild the project. This should cause the resource file to be regenerated and the updated version to be used in the application.
Note that changing the "Custom Tool" property will cause the resource file to be regenerated every time the project is built, so any manual changes you make to the file will be lost.
If you need to make manual changes to the resource file and have those changes persist, you can set the "Custom Tool" property back to its original value after making the changes.
I'm trying to create new resources files in VS2015. I created them fine, but when I try to change the "Access Modifier", the dropdown is disabled...
Any ideas?
I'm working in a ASP.NET MVC 6 (ASP.NET5). The project is a Class Library, but I have tested in Web Project with same results.
Thanks!!
Edit: Added Properties window
Can you check the property of your file and verify if Custom Tool is ResXFileCodeGenerator ? If it's GlobalResourceProxyGenerator, the dropdown will be disabled.
I had the same problem but I found this easy solution Visual Studio's Access Modifier drop down option is disabled for resource file
To summarize:
Right click on your file resource, choose Properties (Alt+Enter)
Change Build Action to Embedded Resource
Change Custom Tool to PublicResXFileCodeGenerator
A) In Asp.net Core projects
This problem is a known bug in Asp.net Core projects and access modifier is on public by default and you can not change it. It will be solved by asp.net core team next updates but if you need internal access modifier you can use my temporary solution:
Add your all items by the resource designer in your Resource.resx and save it
In the solution explorer expand the Resource.resx tree and open Resource.Designer.cs
Replace all public strings in it with internal and save it
Note: every time you save the Resource.resx file you should do the step 3 again.
Finally you should have a Resource.Designer.cs file with access modifiers like this:
Also check the namespace in Resource.Designer.cs file. it should be a appropriate namespace. Sync with your project namespace.
B) In Normal Asp.net projects
If you have not CustomTool property in the Properties panel for your resource (.resx) file to change it to
PublicResXFileCodeGenerator and solve the problem
Then you should change some settings in your project (.csproj) file manually. It's so easy, just follow my instructions:
Right click on your project in solution explorer and select Unload Project
Right click again on it and select Edit .....csproj
In the opened .csproj file, find the .resx string, you will see a block of settings there. That is something like bellow codes.
Change it to something like the following code (include
PublicResXFileCodeGenerator):
.
<EmbeddedResource Include="MyResourceFile.resx">
<SubType>Designer</SubType>
<Generator>PublicResXFileCodeGenerator</Generator> <!--important line-->
<LastGenOutput>MyResourceFile.Designer.cs</LastGenOutput>
</EmbeddedResource>
Save the edited .csproj file
Right click again on your project in the solution explorer and select Reload project
Now open your .resx file and enjoy ;)
Note: use your resource file name instead of MyResourceFile
I've been having a similar problem.
This appears to be a known issue: https://github.com/aspnet/Tooling/issues/339
I have a rdlc file and I try to modify a static text on the file, but when I start the program the text in the form is not modified. I use VS C# 2008 Express. What should I do to be able to modify the text in rdlc file?
You mentioned in a comment that the main form and the report are in different projects. You also stated you added the reporting.dll as a reference to the main project. What MAY be the problem is that you added the actual .DLL of the other project as a reference to the first from "some" location.
In your main solution, did you add your reference and use the tab for "Projects" and pick the project itself? (as opposed to picking a .net library or browse for the physical .dll file.
When you add a reference to the PROJECT, it becomes part of the solution and ultimately part of the building dependency order. The main project would see the project, force to rebuild it, then take a copy of it's final .dll file and pull it into it's own building folder so it always has "the latest" of the underlying reference .dll.
I don't see it in the .sln file, which is what I expected.
Which project is the "startup" project only has any relevance for debugging, which means it's user metadata from the point of the solution and the projects. Regardless of which project is the "startup" project, the compiled code is the same.
Because of this, the information is stored as a user setting in the Solution User Options file (solution.suo) which accompanies the Solution file (solution.sln). The .suo file "Records all of the options that you might associate with your solution so that each time you open it, it includes customizations that you have made" according to MSDN.
The .suo file is a binary file. If you want to read or change it programatically, you have to use IVsPersistSolutionOpts.LoadUserOptions from the Microsoft.VisualStudio.Shell.Interop namespace.
It's in the Solutions User Options (.suo) file, which gets created next to the .sln file.
It seems that the first item in the solution's sln file is, by default, the startup project. So, you could manually edit the sln file to make your project the first project in the solution. Then, a user can override that by selecting a different project to be startup.
Is it possible to programmatically reload a C# project? In one of my previous questions I needed to add all the CS files in a specific folder, now while this works I find that I have to reload the project every time to so that it can register the new files were added.
So now I need a way to automatically reload after the project had been generated.
I assume, for the first time when you output all the DAL files, you are also creating a file with extension .csproj listing in it, all the files you just added in the folder.
If my assumption above is right:
When you want to add more files, you can programatically edit the same .csproj file from your c# code. Then, Visual studio will force the project reload saying it has changed outside the environment.
If my assumption above is wrong:
You can create the .csproj file, It should be easy and straight forward.
I am not sure If I got your question right.