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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With