Recently I've found how to add a link to an item in Visual Studio so that you can reference common or shared files between projects. Editing the original propagates the changes to the projects where the file is referenced. But you can also edit the reference item and the changes are reflected in the original file, is there a way to prevent this behavior?
Reference item is the original file.
If you don't want “the original” to change, copy the file instead of referencing it.
Also, people like editing files.
If some code is not supposed to be edited, make it a binary.
Related
I have a macro-enabled Word document with a reference to a template in the Project > References section of the VBA/macro editor. I can't delete this reference directly. When I delete it through the Developer panel's Document Template dialog box, the template name in that dialog box reverts to Normal, but the macros' Project > References section still shows the old template.
Behavior: the macros fail with the message
"Compile error: can't find project or library."
The missing template appears to be the source of the complaint, since I can create a dummy file with the same name and location as the missing template and the macros load fine. VBA is not relying on any code in that missing template, either, from what I can see. It's just a missing file that's specifically referenced so the compiler chokes. But I need to circulate this macro-enabled document on its own without requiring users to make a new path and copy a dummy file into it.
I've tried editing the XML within the .docm file to remove the reference, but the template is also referenced in the vbaProject.bin binary file. Hex editing that binary file to remove the reference (replacing it with nulls or a valid path/name of the same length) and re-zipping the structure produced a document that Word recognized as corrupted (also tested re-zipping it without making any changes, to make sure the unzipping/zipping process wasn't causing new problems, and that version opened fine but failed at the same place it always fails: the missing template file). Word produced a recovered version, which shows all the macros listed, but it also shows the reference to the template I'm trying to remove.
Windows 10, Word 365 latest
Help?
So I know the usual fix for this error is to delete the extra .resx file that was created when you renamed a form or something else on your application.. But I haven't created/renamed any forms, and I don't see any obvious double .resx files.. This all happened after choosing an.ico file for the icon, that's it.
EDIT:
Well I had 2 .resx files that maybe have been about the same form fDesigner.resx and fMain.resx, the last one which was created an hour ago, I deleted it, but I'm STILL getting the same error, isn't there a file that references the .resx files?
Oh well I found it, might as well answer it myself as well.. There should be a .vbproj file on your application directory, for VB.NET, I'm sure other languages have it different. But you have to edit this, whether you deleted your extra .resx or not:
<EmbeddedResource Include="yourMmainForm.resx">
<DependentUpon>yourMainForm.vb</DependentUpon>
</EmbeddedResource>
In my case Designer.resx was already dependent upon my Main form so even after I deleted the file the duplicate was still there, ok now it's fixed.
I have a vb.net project that has 2 exe's that get built as well as the installer. The two exe's share a bunch of common files. I do not want to have two copies of the common files or mess around with having build events that copy things around (if possible).
My method was to create two projects in the same folder and have them point to the files they needed. This appeared to work until I tried to compile both apps at which point I get an error in a file called Application.Designer.vb. It seems that project files create this file in their folder and when I have two solutions in the same folder they conflict.
So my next effort was to create the second project in it's own folder and just add the items as needed. The problem here is that VS2010 doesn't hold a link to a file in a different folder it copies the file to the new project folder.
What is the vs2010 way to get this done?
You were almost there when you created your second project. Rather than adding the files to the second project, you need to link them.
When you add them, VS copies the source file to the current project's directory.
When you link a file, it leaves it in its current location and just adds a reference to the file to your project. This means that you are operating with a single source file instead of multiple copies.
To link a file, choose Add Existing Item... menu item from the Project menu, select the file(s) that you want to link, and then click the dropdown arrow next to the Add button on the file dialog and select Add As Link.
We have class files that are shared this way among a half-dozen projects, including Win Forms, Silverlight, ASP.Net, Services, and PocketPC.
The easiest solution would be to shove all the common stuff into a common project, and simply reference that project from your other two solutions.
Solution A:
Project A
Project C
Solution B:
Project B
Project C
Just my recommendation anyway.
In a Silverlight 4 app, our user base needs to define for us what content they want on buttons, labels, various screen text, etc. I understand the methods of resource files, but what i'm wondering is when wanting to give that kind of control to the users to define the text in the resource file, what is the best way to let them do that in a way that they can view their changes to the XAML pages? Do they need to have Blend installed?
I vaguely remember when doing a WinForms app, at one point I handed off to the users the actual winform, and they used some sort of visual designer to edit button text, labels, etc., and those changes were then saved to the resource file.
Our app is MVVM, so each item in the XAML would bind to a property in its view model, and that property would then load the entry from the resource file.
If there is a way to let the user update the contents of the resx file while visually reviewing their changes please let me know.
Thanks very much in advance for any assistance.
What I have done in the past is to have a dedicated assembly for Resources (resx) files. By default, they are "embedded" into the assembly. The trick is to change the property on the resx file to NOT be embedded (False). This way, the files are separate resx xml files that must go with the assembly (and live in the same /bin directory of the running application). This is what you see in some /bin directories with the /en-US/ and other resources. In the past, I have created a simply GUI for users to be able to edit these resx files that gets written back to disk. I am not familiar with Silverlight's inner workings for this type of permissions needed, but I would guess at worse case the edited resx files just get uploaded to a server where a new copy is downloaded on next app restart or alike.
Now, when I said "in the past", that was back in 2003 days. Recently I had to do this manually using the ResXResourceReader because of an existing assembly I could not modify.
Some example code (writing it from memory, completely untested):
using (var reader = new ResXResourceReader("[path-to-bin]/MyResources.resx"))
{
var value = reader["My_key_in_the_resx_file"].ToString;
}
Do note that by going this route, you do have access to other types of resources such as binary and files embedded int he resx files.
Lastly, watch your encoding formats. Some over-seas editors use UTF16. So going with a common Unicode converter may be needed.
Also note there is a ResXResourceWriter class, should you want to roll your own writers for updating the resx files through code.
We are developing a CF application and are making use of the default localization/resource handling in the framework (that is, when editing a form in the designer properties like Text have their value stored in the .resx files and the resource manager and framework loads it for us again in the selected locale using satelite assemblies and a call to ApplyResources in the .Designer file)
We have a few custom controls and one of these includes a string property called EditTitle. We would like this value to be stored in the resx file when editing the designer to get the same localization support as the Text property but we can't find anywhere to specify this. We do have an .xmta file for other designtime attributes but we can't find any element in there that would trigger this behavior.
Are there any way to specify this behavior for the particular property. Is it possible to do this for our own properties or is Visual Studio hardwired to only work with a known set of properties and we should be looking for other solutions (like editing the resx file by hand and hoping that the ApplyResources-call picks up and applies the EditTitle property)?
Well, discovered the solution (was pretty self-evident, actually). You can add the following attribute via the DesignTimeAttributes.xmta file:
<Property Name="EditTitle">
<Localizable>true</Localizable>
</Property>
This Localizable attribute will make sure that the value entered in the designer ends up in the .resx file