get a new Properties Settings file in SharpDevelop - c#

If I search here and on other forums how to add a Settings file in SharpDevelop IDE (I use v4.3, installed it when it was new, no need so far for updates), I only find posts of 5+ years ago which state that there's no settings editor in SharpDevelop.
I have an existing solution folder from another project which has a settings file (it's used there for setting default values of some text boxes), and I can edit it in SharpDevelop without problems - so it's built-in now, obviously.
But, how to add a settings file if there's none so far? I can't see an option where to add it, can't find anything in the www for this. Can't be that difficult ...

SharpDevelop 4 includes a settings file template.
Right click the project in the Projects window and select Add - New Item to open the New File dialog.
Open the category Misc.
There should be a Settings template available.

Related

C# Couldn't process file xxx.resx due to its being in the Internet or Restricted zone or having the mark of the web on the file

I have an issue while I try to build project in VS2012.
It cannot build due to the error:
Couldn't process file xxx.resx due to its being in the Internet or Restricted
zone or having the mark of the web on the file. Remove the mark of the web if
you want to process these files.
Here is a similar question.
but I tried that option and had no luck, because I did not download the file from the internet. That project was built from scratch. In project after selecting Properties, in Windows Explorer nothing happened. I do not have the "unblock" option, only the default three options (read only, hidden, and archived).
I have the same error and cannot build or rebuild the project. I have a theory that it is a recent error after updating Windows. Before the update, everything worked fine. Any ideas?
Go to xxx.resx file in Windows File Explorer. Right-click and select properties. At the bottom of the the dialog is an "unblock" option:
Check this and click Apply. Clean your solution and it will build.
In my case I had the same problem with many files.
My solution with VS Prof. 2017 V15.95 was:
Open powershell and execute dir -Path [directory path] -Recurse | Unblock-File
Rebuild all
On the solution folders locate abc.resx.
Open the file using any text editor, preferably Notepad++.
Locate and delete any node starting with <data
Example. This is what you should delete.
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAMAICAAAAEAIACoEAAANgAAAGBgAAABACAAqJQAAN4QAACAgAAAAQAgACgIAQCGpQAAKAAAACAA
AABAAAAAAQAgAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
///////////8AAB/////////
</value>
</data>
Reload or reopen your solution and build. You are ready to go.
Had the same problem after updating to VS 2017 v15.8.5, and none of the solutions above or on other forums worked for me.
So, since a .resx file is just XML, I just copied the content, deleted the original file and recreated it with the copied content.
That was the only thing that worked, and it worked first time.
A quick way to remove this mark of the web for multiple files and folders recursively for me was to
Zip them up.
Delete originals.
Unzip.
I'm not really sure either, I have the exact same issue.
But, what i did, was hit view in file explorer.
Then, i clicked show hidden items.
Finally, i went back to my folder and clicked on the .vs folder, my project/file name, v15, Server, sqlite3, and deleted DB.Lock.
I reopened the project, clicked build, and it worked perfectly.
This worked for me, it might/might not for you.
I also encountered this issue recently. The error began occurring after I set the icon of a Windows Form.
Researching for the cause and solution almost led me nowhere, because I did not download the icon from the internet, nor was I referencing a web-based icon file. It was stored entirely on my local machine.
After some more researching and digging around, I was able to figure out exactly what was causing the problem. I have Microsoft One-Drive installed on my machine. The directory in which the icon file was located is managed/synced by One-Drive. That fact was somehow tricking Visual Studio into believing the file was located or downloaded from the internet.
The solution proved to be very simple. I removed the icon from the form, as well as from the corresponding .resx file. Then I moved the icon file to another directory not associated with One-Drive. Finally, I was able to use that icon in my Windows Forms application without getting this error.
I understand there are other possible causes for this error. But if in your case, the issue happened after setting a form's icon--and if you have One-Drive (or perhaps another cloud-based storage solution) installed--then check to be sure that icon file is not in a directory managed by that service. If so, relocate it and change the form's icon property to point to the new location.
To fix this for multiple files within a project, Visual Studio -> Tools -> Options -> Trust Settings and add the project path as a trusted path.
Using VS 2019, and building against source stored on an Azure shared file system. I think I may have just tracked down a work-around, and it has to do with the Icon as referenced above by Jake above. If I add the icon to the form's resource file (that really long string), The error occurs.
However, if I add the Icon to the Project's resources, delete the Icon from the form's resource file, and change form to set the Icon manually...
this.Icon = MyProjectName.Properties.Resources.MyIcon;
The error goes away.
I found this solution on another forum. My project resided on a file share, so I had to enter file://[file share] for Step 4 below. I am running VS2019 on Windows 10.
Start Menu > type 'Internet Options'.
Select Local intranet zone on the Security tab then click the Sites button
Click Advanced button
Enter file://[computer name] or file://[file share]
Make sure 'Require server verification...' is unticked
I had the same issue in Windows 10 VS 2019 16.4.457 (previous version of VS 2019 had no problems).
The "marked for web" error shows only after I moved the project under One-Drive.
If I move the project back to a local drive the error doesn't show.
As Anthony Gingrich suggested, I tried to move the project images to a local directory without success.
The solution that works for me was, for each image, in the "Select Resource dialog" use "Project resource file" instead "Local resouce".
Please guys, I already fixed the issue, this is cause by OneDrive, please close your OneDrive with the use of task manager or close the icon OneDrive's Hidden Icons on the taskbar
I just ran into the same issue and also tried the Unblock option from explorer with no luck. I even restarted VS with no luck.
However, I'm not sure which combination did the trick but I opened the form as well as the resx file from within VS, just to see if I can open it, which opened fine. I then did a clean and rebuild and that appeared to do the trick. If it doesn't try restarting VS after the clean then rebuild.
I had a similar issue and the problem was an image that I had downloaded and added to my Resources. Not completely sure why that was the only image that gave me problems, however, I opened my abc.resx file giving me issues an a text editor, removed the node starting with " (it was the last and only node) just like Albert Alberto mentioned. Saved the changed, cleaned and rebuilt my solution and it all works! The image didn't render but it only took a second to go back and add the image. It wasn't removing the entire file, just the node that was causing the issue.
I had the same problem on Windows 10, VS 2017 (15.9.13). I sent myself a project from work through Dropbox so I could try a couple of things from home. But when I tried to build it VS gave me the 'marked for web' error.
After trying the solutions above without success I began experimenting. I was able to solve this by using the method listed above (right click -> properties -> unblock), but I had to do it for each of the images in the Resource folder--and I had to do EACH FILE individually since the 'unblock' option was not available on group-selects. I actually unblocked each source file in the project as well before trying to rebuild so I am not sure if both are required.
Its a bit of a pain--probably a huge pain for larger projects--but it absolutely got the project building again.
EDIT: I did find this article afterwards about unblocking entire folders--even recursively but have not tried it: https://www.winhelponline.com/blog/bulk-unblock-files-downloaded-internet/
None of these worked for me. I fixed it by converting the embedded base64 into a linked resource:
I found out the issue was with the embedded base64 image I had in the .resx (as the issue went away removing the data tag as explained in this question but that meant I removed the image) so I converted the embedded image into a .png file and made a link to that in the .resx.
To do that: open the .resx file in Visual Studio 2019 and double-click the image, and then click Ok and Yes in the following prompts that will appear so VS will convert the embedded image into a linked resource (sorry I can't upload pictures yet):
Hope it helps!
From my original comment.

Add registry file (*.reg) to setup project

I see how to update the registry manually, by right-clicking on the project, select View, then Registry, but I have alot of registry changes that I need to incorporate into my setup project, and I've already exported each of them to a *.reg file. I don't want to have to go through and add each of them for the setup project manually again.
How can I add my *.reg registry files into the setup project?
As noted in the comment, right-click the "Registry on Target Machine" root node and click Import. It will ask for a .reg file. And will populate the tree with what it found in the .reg file. Just repeat this if you have more than one .reg file.
The Setup project designer doesn't exactly have the most discoverable user interface. It uses right-click context menus a lot and commands are scattered between context menus, regular menus and buttons. So if you are looking for a feature that you think ought to be there then some wishful left and right-clicking on UI widgets can help you get lucky. Spending ten Friday afternoon minutes clicking away is advisable. Note that it was removed from VS2012 and won't come back, it is still available in the gallery.
Just right click the project and add the file to your setup project. Have your application go through the .reg file on first run to make sure the registry is properly set up.
You may add or update your .reg files programatically. Let's say, for example, that you may want to merge a given file.reg to your registry:
Process _re = Process.Start("regedit.exe", "/s file.reg");
_re.WaitForExit();
(Just keep in mind that newer Windows versions use Unicode instead of ANSI when creating/consuming .reg files.)

Reuse a solution for a new task

I am new to C# and Sharepoint Web Services. I wrote a program awhile back, and I want to use that program as my starting point for the next project. It has all the references and resources already in place. Essentially, I want to copy the solution, and rename it, then change it to meet my current needs.
What's the best way to do that?
Try this:
open Windows Explorer, copy your solution and its folders, paste into a new location.
rename your copied .sln to something else (hit key F2 from Windows Explorer)
open that copied solution, and rename the solution (and perhaps your projects within)
You can open the old project in visual studio and then go to File --> Export Template and follow the wizard.
This will allow you to create a project template that will then be available with all your other project templates in File --> New project.
You can do this per project (or per item which will not help in your case). It then automatically renames your namespaces etc. if the template is configured correctly.
The most straight-forward approach would probably be to just create a new solution, then manually copy all the projects under that solution and add to the new solution (right click on the solution name in Solution Explorer -> Add -> Existing Project.
From there, rename the projects if required, being careful to keep things like the Default namespace and Assembly name consistent with your new project name (you can find these under each project's properties page). Also keep an eye out for any paths that might need changed in the pre / post build steps. You will probably also want to rename the existing namespaces (right-click the namespace in code, Refactor -> Rename...)
Also, this might be a good opportunity to spot which projects will be common to both the old application and your new one, and possibly moving these to a third location from which both solutions can reference them.

Creating default set-ups for commonly used code in Visual Studio 2010?

This is a pretty minor annoyance, but I noticed that every time I create a class in Visual Studio there are a few things that I would like to be automatically-generated for me. For instance, all of my classes start with a log4net declaration. It's only one line of code, but it's annoying having to find a class where I declared it in to copy/paste from.
In addition, there are multiple common 'usings' which I use, but that are not created by default.
Is it possible to setup VS to do this?
You just need to edit the default Visual Studio Class template. A walkthrough of the process can be found here.
From the File menu, select "Export Template".
You can create your own item/project templates. Here is a primer from MSDN:
http://msdn.microsoft.com/en-us/library/6db0hwky.aspx
Basically you'd create your own custom class template.
From MSDN:
Creating Project and Item Templates
How to: Manually Create Item Templates:
Create a project and project item.
Modify the project item until it is ready to be saved as a template.
As appropriate, modify the code file to indicate where parameter replacement should occur. For more information about parameter replacement, see How to: Substitute Parameters in a Template.
Create an XML file and save it by using a .vstemplate file name extension, in the same directory as your new item template.
Author the .vstemplate XML file to provide item template metadata. For more information, see the example in the following section.
Save the .vstemplate file and close it.
In Windows Explorer, select the files you want to include in your template, right-click the selection, click Send To, and then click Compressed (zipped) Folder. The files that you selected are compressed into a .zip file.
Copy the .zip file and paste it in the user item template location. In Windows Vista, the default directory is ..\Users\\Documents\Visual Studio 2010\Templates\ItemTemplates. For more information, see How to: Locate and Organize Project and Item Templates.
Although not exactly what you are asking for, one option is to declare code snippets. This will allow you to leave the standard class alone (not change the template) and add in the pieces that you require without having to find a class with it. However, if all your classes for every project you create requires the same basic set of code then Templates are the way to go.
C# Code Snippets
How to use them can be found How to Use Snippets

Transfer all ReSharper Settings between PCs

I was wondering if there is a way to copy ALL my settings from ReSharper (including the StyleCop for ReSharper settings and the keyboard bindings I have set for ReSharper) from one PC to another?
Since the export option within Resharper is only for code styles, you'll need to be a bit craftier for all settings.
From Peter Ritchie's blog...
...the settings are stored in
"%userprofile%\application
data\jetbrains\resharper\v4.0\vs9.0".
There are a couple of xml files in
there that store your settings.
Before you upgrade to the latest
build, just copy those to another
directory.
It's very likely that the format of
these files has changed since the last
build so copying the backups over the
new version could possibly make
Resharper to blow-up. So, use with
caution.
I have Resharper 4.1 so instead of "...\v4.0\vs9.0" it's actually "...\v4.1\vs9.0" (obvious, I know, but worth mentioning).
I'm not sure about StyleCop settings, but this should work for most other settings (keyboard scheme, code completion settings, etc...).
There is a R# settings manager plugin for resharper that stores all of this I think, including stylecop settings
Open Visual Studio
Go to Resharper > Manage Options
Click on Import and Export
Click on Export to File
Tick all check box
Click on OK and save the file to your desired location
To import the settings to other computer, repeat steps 1-3 and then select Import from File. You are done.
Enjoy!
You can Export/Import your ReSharper Code Style or put it on the network and share between multiple computers. To do so:
From VS Menu select ReSharper -> Options then in Option dialog select Languages/Common/Code Style Sharing.
Not sure if it's exactly what you're looking for.
StyleCop settings are not stored in the resharper plugin. they are in the stylecop directory and in an xml file (Settings.StyleCop).
I have a solution that i am using!
Skydrive and junction link magic.
I create a junction in the filesystem that point the settings to a skydrive folder.
this way i have everywhere i use skydrive the same settings!!!
On the target pc i do the opposite.
Hope this helps.
Steve Dignan's answer is probably correct for 2009 version of Resharper.
In newer versions of Resharper global for PC Resharper settings are located in:
%userprofile%\Appdata\Roaming\JetBrains\Shared\vAny\GlobalSettingsStorage.DotSettings.
Solution team-shared settings are in the solution folder called {Solution Name}.sln.DotSettings.
Solution's personal settings are in {Solution Name}.sln.DotSettings.user.
Source: https://resharper-support.jetbrains.com/hc/en-us/articles/115001216530-Where-to-find-DotSettings-files-associated-with-settings-layers
So to transfer settings between 2 PCs, copy settings file(s) for the appropriate layer(s) you want to transfer and that's it. Usually just copying global is enough.

Categories