I created a new class library for windows store apps and within this library I created a Usercontrol in a folder named 'Controls'.
I use this class library in another project (especially this controls mentioned above) and everytime I try to run this project a weird error occurs:
"Payload file 'C:\PATH TO CLASSLIBRARY FOLDER\bin\Release\LIBRARYNAME\Controls\Usercontrol.xaml' could not be found"
So I opened my library's folder and looked up this path.
The path described in the error message does not exists but if you would replace
\bin\Release\LIBRARYNAME\Controls\Usercontrol.xaml with \bin\Release\Controls\Usercontrol.xaml then there is the wanted file.
Then I simply copied the \Controls\ folder containing Usercontrol.xaml and pasted it into the newly created folder \LIBRARYNAME\Controls\Usercontrol.xaml.
Now this error doesn't occur anymore but I don't want to do this copy-paste action everytime I modify Usercontrol.xaml?!
Does anybody know why this happens? Is there a way to avoid my inconvenient solution?
Thanks for help! :)
After doing some further researching with the exacty english error message (worked with german vs2012 by then) it seems that this is a bug in Visual Studio.
More info about this:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/51111470-8a86-44d4-acb8-e268afa7564e/
Related
Hi I have been working on a school project recently in visual studio using c sharp. Some of the files had become corrupted, I'm not sure why and the file structure was all messed up so I decided to create a new project and import the existing good code into the project.
After some cleaning up the project almost runs but fails when trying to access the Resource file:
this.pictureBox1.Image = global::Coursework.Properties.Resources.PictureOne;
This is definitely the correct path, I wrote it using auto completion and the PictureOne image is definitely in the Resources file.
At this point and I get the error:
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
The error occurs at any time of trying to access the resources file. I noticed this in the error given which I thought was strange:
.. "Coursework.Properties.Resources.resources"... I don't know the second resources with the small "r" is referring to. I think it may be a namespace issue.
Thanks for any help!
You can follow this steps to resolve your issue.
Open the project that contains the localized form class where you receive the error message that is mentioned in the "Symptoms" section.
In Solution Explorer, expand all folders.
Right-click Form1.resX, and then click Properties.
In the Form1.resX Property Pages dialog box, expand Configuration Properties, and then click General under Managed Resources.
Change the Resource File Name property from $(IntDir)/ .Form1.resources to $(IntDir)/ . MyForm .resources, and then click OK.
Note MyForm is a placeholder for the class name of the form class that you localized.
Press CTRL+SHIFT+S to save the project. Press CTRL+SHIFT+B to build the solution. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
824495 (http://support.microsoft.com/kb/824495/ ) FIX: You receive a "MissingManifestResourceException" error message when you add a linked resource in Visual Studio .NET 2003
Press F5 to run the application. The application runs, and the Form1 form is displayed.
Here is the detail information about your issue.
http://support.microsoft.com/kb/318603
KB: You may receive a "System.Resources.MissingManifestResourceException" error message when you access the .resources file of the form at run time
I have a working Android Project with a .Droid-Solution and a SharedProject. I started the App on my phone and it works great. Now, I just added a blank Windows 10 Universal Solution and did the instructions here: http://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/
Anyway... I did nothing else. Just followed the instructions and tryed to start the Windows 10 Universal app, but I get this error:
"CS0103 C# The name 'InitializeComponent ' does not exist in the
current context."
I googled a few times, but didn't find something that helps.
I also tryed the example here: https://github.com/jamesmontemagno/Hanselman.Forms with the same error.
Does someone know this error with Xamarin.Forms and Windows 10 Universal Apps?
Everytime you create a .XAML page in Xamarin.Forms, you are using partial class definitions in three different places.
Your actual .xaml file will have a Class="" attribute on the root element that defines the namespace and class name.
The actual root element type will define the base class that your new .xaml page is subclassing. By default, that would be ContentPage.
You also get a .xaml.cs file that is linked which contains a partial class definition as well. This is your code behind file, where you put page specific code, this is also where the InitializeComponent() call is called from the constructor.
This call serves to parse the xaml contents and fill out the references to all the views you gave ids to using x:name="something" in xaml.
InitializeComponent() is automatically generated by xamarin, it is part of the output of your project and it should get re-generated each time you edit your .xaml file.
In order for this to happen, in the properties of your .xaml file Build Action needs to be set to "Embedded Resource" and the Custom Tool needs to be set to "MSBuild:UpdateDesignTimeXaml"
Now, even with these values set correctly, there are bugs in Xamarin which can lead to the file not getting generated and you getting the error.
The absolute first thing to try when you get this error is to right click the .xaml file and click on "Run Custom Tool".
You only need to do this once, on ONE xaml file, the tool will automatically run for all the .xaml files in your project.
This is somethign that I have to do about once a day during my normal development and it started when i switched to VS 2015. Your mileage may warry.
Another very important thing to check is the BuildTargets in your .csproj file.
The way Xamarin is able to do it's thing is by specifying build actions that call into it's DLL that you get when you install the Xamarin.Forms nuget package. Sometimes the build actions import line get's messed up and this causes all sorts of problems.
Unload your .csproj and find the line that imports Xamarin.Forms.targets.
It should look something like this:
<Import Project="..\..\packages\Xamarin.Forms.2.0.0.6484\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.0.0.6484\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
make sure that the version in here matches the version of Xamarin.Forms from your packages.config file, then make sure that you can actually navigate to your project's root folder, and find the actual file the important line is referring to. Ie, packages\xamarin...\Xamarin.Forms.targets
A common thing to do is to delete everything from \packages\ and let nuget re-download everything on your next build. Just make sure the version in your .csproj import and the version in packages.config is the same.
If all of these are done, you should have a valid generated partial class that implements InitializeComponent() and the errors should dissapear.
Just as an update to this:
New, clean Windows 10 Pro installation with all updates in a VM.
New, clean Visual Studio 2015 Community Edition installation with all options selected and all updates.
New project: Blank Xaml App (Xamarin.Forms.Portable) with nowt but generated code.
The project will not build as InitializeComponent in App.xaml.cs does not exist in the current context.
Opinion: this Xamarin add-on is a free add-on on top of a free product, but even so this kind of thing doesn't really inspire you to use it...
I have been working on c# Gui for about a week without problem, all of a sudden when I added a label control I tried to access its events and saw the error "This document item has no code behind file. Add code behind file and a class definition before adding event handlers"
This is odd since the gui/methods still runs fine but it is making it very difficult to progress...any ideas? Did a file get deleted etc? Can provide more info on request, thanks for the help!
(couldn't add screen shot unfortunately yet but error is displayed in properties window/event tab)
I encountered the same error"This document item has no code behind file. Add code behind file and a class definition before adding event handlers" in my first C++ Helloworld project when I try to add a even handler for one button I added in the MainPage.xaml.
I solved the problem by restart Visual Studio 2015 and recreate a new project, then I add a even handler for the button successfully.
It's my experience and just be posted here that maybe you can use it as reference.
I ran into this, too. In my project, most UserControls were fine, but there was one group that showed the "no code-behind" message instead of properties. The .cs files did exist, though. In the Solution Explorer tree, the xaml files all had xaml.cs files. I checked the csproj file, and all the xaml.cs files were tagged as <DependentUpon> the correct matching xaml file.
I was able to fix this by closing the solution, then deleting the csproj.vspscc (Source Control Project Metadata) file for the project. When I reopened the solution, that metadata file was rebuilt and the Properties were available in Visual Studio again.
First thing when I try to run the application (I just downloaded it from CodeProject, right here), I get this error:
The name Resource does not exist in the current context
So when I double click the error it takes me to this code:
private Image mp_CodeImage_Class = Resource._class;
But there is a class called Resource but is in a file called Resource.Designer.cs, and this file is in a resource file called Resource.resx. When I check the properties of Resource.resx, Build Action is set to Embedded Resource and Custom Tool is set to PublicResXFileCodeGenerator. I'm just saying this details in case they help you find a solution because I know nothing about resources, just almost never use them. Hope you can help. Thanks.
For one, you can't open .sln files (which are VS solutions) in the express versions.
So what you will need to do is open the project file (.csproj), compile it, close that project and then copy the dll which you've just compiled into your project in which you want to use the control.
Hope this helps.
While working on an existing project I suddenly got the following error when trying to compile the solution:
error MSB3105: The item "[filename]" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
Now, as far as I'm aware, I did not make any change to the project that affects the resources. Also I have checked each and every file within the project, but there is no duplicate reference anywhere to this file.
Now I already found some forum entries regarding this error:
1) Open the .csproj file and remove the duplicate reference. [Tried this, but I cannot find any duplicates in it]
2) In a 'partial class' project, move everything to a single class. [ Could try this, but the project has been split up into partial classes since the start, and I do not want to change this just because of the error ]
So what else could cause this ?
Did you try showing all files in the Solution Explorer? You could have a duplicate .rsx file somewhere in there.
I found the answer in .NET forum posting by Roy Green, and Theresa was right after all, though I did not recognize it.
If you have your main form class split up into partial classes, the partial sections end up in the solution explorer as separate items. And if you double click on them they show up in the designer mode as a normal form. But if you (accidentally) drop a control on these forms, Visual Studio creates a new .resx file and a InitializeComponent routine for it. But since this form is actually just part of the Main Form class it leads to the 'duplicate resources' error. And there is no other solution but to remove the InitializeComponent routine and delete the .resx file by hand.
Be sure that under yourForm.cs no duplicate resources are defined (.resx). If you renamed your Form, remove the old resource because the new one during compile will be created with the new name.
I just made the same mistake. Delete the mainform.designer.vb, then I restored it again from the recycle bin, and found this error message when compiling.
I try to search on google and someone suggested to check on .vbproj. Did that and found a duplicate on some line.
I had this as well, in VB. There is the "real form" file frmMain, and then I had created new class files and modified them to be Partial Public Class frmMain. For example, I have an ImportFromExcel.vb Partial Class file (I didn't want to clutter up the frmMain.vb with the rather complicated Excel import code.)
Everything worked fine until I decided I wanted to use an OpenFileDialog in the Sub ImportFromExcel. I dragged the OFD from the toolbox over to the Designer view of the ImportFromExcel file. (I have no idea why this view exists, if you can't do anything with it!) But at any rate... dragging the OFD to the Partial Class Designer created an ImportFromExcel.resx file. The drag/drop operation also created an InitializeComponent sub in ImportFromExcel, which is redundant and shows an error -- easily corrected with a little editing.
Ultimately, I chose to not use the dragged resource, but localized the code in the ImportFromExcel.vb file.
All you really have to do is right-click the ImportFromExcel.resx file, and choose Delete. Everything else seems to "fix itself", and it builds fine now.
In my case, this problem happened because a file had the same name but not the same case in the GIT repository.
For example MyFile.cs and myFile.cs.
If you do a checkout on windows, one of the files is overwritten by the other (no message, no warning). So, it is compiling, and we don't notice anything. But if you try to compile on Linux (with .NET Core) both files are present, and there is this error at compile time.