I am working on an existing windows form application. I only need to make few modification, during those changes i came across a scenario where i need to rename an existing namespace aswell. Now after renaming that namespace my project is not running. Although it compiles fine but breaks at the following line of code
ImageList il = new ImageList();
ImageList = il;
il.Images.Add((Image)new Bitmap(GetType(), "Images.ImageFileName.png"));//when this line is executed a dialog box appears and says that "there is no source code available for current location"
Now since i am new to .net world so i study this problem and figure that it arises due to change in namspace. I also trying renaming the namespace in the Resources.Designer.cs
but it also didn't solve my problem
Thanks All.
I find the solution by myself. The purpose of posting solution here is that may be some one else benefit from it.
Infact its a sort of carelessness from my side because i forget to change the value of Property "Default NameSpace" this property contains the old namespace that's why my resource file alwasy point to old namespace
Right click on Resources.resx, select Properties, find Custom Tool Namespace, set the namespace that you need.
Also, why don't you reference your resources in the typed manner like Resources.ResrouceName.
Here is a quick tutorial how you can setup your resources so you don't have to cast and think about namespaces: http://msdn.microsoft.com/en-us/library/7k989cfy%28v=vs.80%29.aspx
try getting rid of that second line, ImageList = il;. what it's doing is replacing a class with an instance of a class. not good.
I have also came across this issue. I had to rename the namespace of my application. After that the designer was ignoring all resources, although they were appearing after building a solution and running the application.
I found that even though I had renamed the namespace, it wasn't replaced in Application Properties under "Default Namespace" textbox. I have changed the old namespace which was still appearing there with the new namepspace and it worked properly afterwards.
That specific overload of the bitmap constructor combines the namespace of the given type with the string name of the resource and looks for a match in the assembly manifest. So in this case it would be the namespace of your class + ".Images.ImageFileName.png". I'm guessing that does not exist. Change the namespace of the Resources.resx by right clicking on it and selecting properties, do a Rebuild and see if it works now.
Related
I've written an extension to provide IntelliSense auto-completion for an VS Isolated Shell. The issue I'm having is making this auto-completion apply only to files of a particular file type. I've followed the guide here to do so.
Relevant class file:
using Microsoft.VisualStudio.Utilities;
using System.ComponentModel.Composition;
namespace VSIXProject1
{
internal static class FileAndContentTypeDefinitions
{
[Export]
[Name("assembly")]
[BaseDefinition("text")]
internal static ContentTypeDefinition hidingContentTypeDefinition;
[Export]
[FileExtension(".asm")]
[ContentType("assembly")]
internal static FileExtensionToContentTypeDefinition hiddenAVRASMFileExtensionDefinition;
}
}
Despite this, when I put the [ContentType("assembly")] export on the ICompletionSourceProvider and the IVsTextViewCreationListener that are used to handle the IntelliSense integration, the auto-completion fails to show up at all. However when I use [ContentType("text")] or [ContentType("plaintext")] the auto-completion will show up on either all files or just .txt files, respectively.
This is the first VSIX plugin I've tried to make so maybe I've missed something. Currently, I'm at a loss for what to try next. A lot of googling hasn't yielded much information, and the code resources I have found seem to implement this behavior in the same way I'm attempting to.
So after a few unsuccessful attempts, and a stroke of luck, I realized what my issue was. The specific Isolated Shell (Atmel Studio) I was trying to write the extension for already had a ContentType for assembly files. I'm guessing that when I added my own content type it was overwritten by the shell itself.
In order to fix the issue, I used the ContentType name that the shell uses which happened to be "assembler". This happened to be a lucky guess based on the languages that appear under Tools > Options > Text Editor. Hopefully, this helps someone who runs into the same issue in the future.
I moved a class from one namespace to another, and now I have over 2000 errors to go through.
All the errors are related to the class that I moved, is it possible to implicitly or globally add a namespace to all my files somehow?
Or is the only way to manually go and fix each error?
I have ReSharper, but I am weary of making a global change and not even sure if Resharper go fix this ONE issue in all the files?
With ReSharper you can right-click the class name, select Refactor from the popup menu and select Move... select Move Type To Another Namespace. ReSharper will change the namespace and correct all the files referencing the new namespace, an option if you can rollback your move.
Are you implementing the using statement on your classes that are calling this class?
If so, just use the search and replace for the entire solution from the old namespace to the new name. It will do it with. If they are in seperate projects in the same solution, you will have to add. a reference to that project.
I am writing a program for computer vision in c# that part of project SIFT is needed; I downloaded the MEMO library for SIFT :
http://www.nowozin.net/sebastian/tu-berlin-2006/libsift/
In my project I added the two libraries ****libsift.dll & ICSharpCode.SharpZipLib.dll** ** as references in to my projects.
Now that I want to mention libsift on top of the code " USING libsift" it doesnt recognize it;
even more if I wanna make a instance of such class atuo detect doesn't recognize it.
It is weird because I could see the functions of this library in object browser.
I couldnt use the library that I have already imported as references in my project although I could see the functions in object browser? What could be the problem?
(I have c# .Net VS2010 in windows.)
It looks like they're in the root namespace - not in a namespace called libsift. If that is the case, you don't need a using libsift; directive - just try accessing Keypoint etc directly. Or possibly global::Keypoint. It should be noted that dumping types into the root namespace is frowned upon - it makes it hard to avoid conflicts. But that is the fault of libsift.
The other possibility is that you've changed the "Aliases" property on the reference; that should be "global". You can see this in the property panel when you select an individual reference in the solution explorer - alongside things like "Copy Local", "Specific Version", etc. If it is anything else: change it back to "global", or learn about extern aliases.
Tested locally (the types are in the global namespace):
Thanks for your time everyone.
I'm working with C# .Net 4.0 and Visual Studio 2010 Professional. I have a few buttons, a richtextbox, and a splitcontainer on the form. There isn't a whole lot of code, and it doesn't really do much at the moment. There are two projects in the solution: call them MyProject and MySupportProject. The form is located in the MyProject project.
Every once and a while when I try to run the program, I get two errors:
'MySupportProject.Properties.Resources' is inaccessible due to its protection level
'MySupportProject.Properties.Resources' does not contain a definition for String1'
So I go look at the designer, and for some reason it keeps filling in the following:
this.rtbStatus.Text = global::MySupportProject.Properties.Resources.String1;
And I have no idea why. I delete it or comment it out and it keeps generating that line. The RTB (RichTextBox) in the form has no text associated with it.
In the solution properties, MySupportProject is listed as a dependency of MyProject, but I can't for the life of me figure out what it is trying to do with this particular RichTextBox with that particular non-visible string. I looked into the resource in MySupportProject a little bit and found the definition:
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string String1 {
get {
return ResourceManager.GetString("String1", resourceCulture);
}
}
It looks like the above definition was generated by some tool, but I'm really not sure where it came from. Someone worked on this project before me, so they could have put it in, but I started the form from scratch and I'm not making the connection. Has anyone ever had a similar issue? If not, is there something else I should try to stop this annoying occasional build failure? Thanks for all your help!
I don't exactly know reason behind this, but you can just replace the line with this:
this.rtbStatus.Text = "";
or:
this.rtbStatus.Text = null;
Also, try delete that string resource of yours. If you can't then do this:
Check if there are any other resources stored in the resource file.
If yes, then copy all the other resources into a new resource file and delete the old file.
If not, then just delete the old resource file (.resx) and create a new resource file.
When I try using a Name="id" and\or x:name="id" I get a compiler error:
The Type 'MyName' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
When I don't have this specified my control runs just fine. Any suggestions?
Well, first of all the right syntax is x:Name, although Name by itself usually (but not always) works too.
Does the x:Class on your root-level element match the name (and namespace!) of your code-behind file? I know that some versions of Blend and VS didn't insert the default namespace correctly, and of course if you've changed it from the default you'll need to make sure you've changed the other file as well.
I've run into this before and believe it's a compiler bug. I ended up just sticking a named ContentControl in my XAML and sticking the user control in it from the code behind. Hopefully someone can share an actual fix for this.