UWP Media Element Custom control giving exception - xaml

I am having a very strange situation over here.
I refered to the UWP samples and tried Custom Media transport controls sample. I ran it and it was working just fine, like its supposed to work. But then I tried and made my own project and I copied exactly everything which was in sample project not even name of file or folder was different. And then when I ran that project it gave me debugger unhandled exception and open App.ig.cs some file like this and when i continue it stop debugging. Below is the attached snapshot of that error. Any help is appreciated this is a really strange error for me as it makes no sense at all.
Note: I have tried to run it in both blend and visual studio

I solved it by simply ignoring the style of transport controls provided in the sample, for some reason that style was not able to verify some properties so I deleted that file and made my own style file, I copied the style of default media controls and edited them, it worked for me :)

Related

Values cannot be null. (Parameter 'baseName')

When trying to open the form deisgn it says values cannot be null. (Parameter 'baseName'). I still can run the system without error. Dont know how to fix it and have to change some gui design. Help me its for my school tnx
I had this problem this morning and a few hours later I decided to just start over and copy the code from the old project to the new empty project. Everything is working in the new copy of the project. I copied from old to new by drag-n-drop. I copied all the UserControls before I copied anything that uses them, and built, then copied over the remaining things, and went through all the errors caused by the change in name of the top-level Namespace.
(All of the Namespace errors were in the .Designer.vb files. I have posted elsewhere "never edit those files by hand unless you know what you are doing." This case was one of the rare exceptions.)
I had the OP's problem that when I tried to open a Form in the designer, I got the message
Value cannot be null. (Parameter 'baseName')
It didn't matter if I tried to open the Form in Solution Explorer or by pressing Shift-F7 in the Form's code window. However, sometimes Shift-F7 resulted in a wait cursor followed by silence - no error message.
Like the OP, the project did run without errors (well, same bugs as before but you know what I mean).
Another symptom: If I launched VS and tried to open the Form designer before Intellisense was initialized, instead of the other error, the window that should show the layout of the Form showed this instead:
File path: full path of the file I was trying to open
Frame GUID: 2c01570-c72c-11d0-88c3-00ac0c9110049
Frame mode: VSFM_MdiChild
Error code: 0x80131500
There are no MDI containers in my project. It's a reference to VS 2019.
The same error occurred in every Form and UserControl in the project.
The same error occurred in any new Form or UserControl that I added to the project.
The error did NOT OCCUR in any and all other projects built in VS 2019 with a target of .Net 5.0
The error DID OCCUR with the same project on another machine running a clean install of a later version of VS 2019.
Attempts to Clean Solution or Clean Project failed, with a generic error message, it was something like "Clean Project failed."
Nothing about these problems appeared in any event logs.
Every time the problem happened, when I shut VS, one process was left running (per TM).
Here are some other things I did to try to suss it:
Ran a repair install on VS 2019 and reboot.
Opened each and every VS-generated file in another project and compared them line-for-line (most are text) against the corresponding files in the broken project. No data-independent differences.
Searched exhaustively with 3 search engines and many terms for someone else that posted about this error. This is the only post I found.
Deleted, renamed, or moved files that are automatically generated by VS, including some Json files, XMLs, and caches.
What I did not try:
Roll back the code to the most recent commit.
Uninstall VS 2019 completely, reboot, install VS 2019 as if an initial installation.
Just had the same experience. I took me a while before I got everything to work again, but the clue in my case was that I had added a new item to my project, and for some reason I had managed to delete the file name in the process so the only thing left was 3 new files with only the extensions .resx, .cs and .Designer.cs
I quickly deleted the ".cs" file but forgot the rest.
Suddenly I was unable to open my main form in the designer - and the “Value cannot be null. (Parameter 'baseName')” started to appear. It was only affecting my main form.
I tried almost everything described above except the reinstalling part.
But then I deleted ".Designer.cs" and ".resx" from within visual studio (Solution Explorer), and then the problem went away.
I started getting this error after using a hack to support generics forms (e.g. MyForm). The designer generated a file:
MyForm.resx
which worked for design time (even with the form being generic) but crashed at runtime. My hack was to rename the .resx file:
MyForm`1.resx
However that is when the Designer stopped working. It stopped working for ALL forms/user controls in entire solution (not just the generic I was experimenting with). I assume there is some kind of process that crawls all the resx files whenever you open any Designer and that is the source of the Exception.
I was able to work around the issue by:
Renaming the resx back to its non generic title (i.e. MyForm.resx)
Restarting visual studio.

Codewarrior 10.5 broken links from problems window to errors in code

Typically when I compile a project I am working on in Codewarrior, the Problems window displays the errors and warnings it finds. From there, I am able to click on the errors and I will be linked to the location of the error in the code. In the current project I am working on, the errors are displayed in the problems window, but they do not link to the error. It shows the correct file and path, but the hyperlink to the location in the code is broken. In the console window, I can use the Next/Previous error buttons to navigate to error, but I can't do this from the Problems window - which I find easier to read. I know that this error is limited to this project, because I have opened other projects since this started happening and do not experience this problem in those projects. When I started this project, I copied an existing Codewarrior 10.5 project that does not have this issue and began changing names and editing. I have a suspicion that I might have missed something during this conversion process, but I am running out of places to look.
I'm not sure the exact reason for this error, but I did correct it by deleting the folders in the workspace folder and re-importing the project.

Xamarin Forms InitializeComponent does not exist

I am learning Xamarin Forms for Visual Studio 2015 and trying to create a simple Shared project using Xaml but I keep getting InitializeComponent does not exist (as well as any reference to Xaml controls in cs classes).
It is my understanding that in the latest versions of Xamarin, Xaml works in Shared Xamarin Forms Projects (and not only in PCL projects). I've tried running the latest betas that got released less than a month ago but still no luck.
Any advice is greatly appreciated.
Turns out I had to manually change the properties for all Xaml files like so:
Build Action: Embedded resource
Custom Tool: MSBuild:UpdateDesignTimeXaml
For some reason adding new Xaml forms files doesn't set these by default in VS2015 with latest Xamarin.
I had the same issue. And it turned out to be that fully qualified Class Name (x:Class attribute in the main node) in the XAML file must match exactly the xaml.cs file's name. I corrected the namespace casing and it worked!!
This happens when your XAML markup is invalid. There is a background compilation task that parses the XAML file and generates a code file (this is normally hidden from the developer) which declares those control references. If your XAML is not valid then this task will fail silently, and your first hints are the symptoms you describe.
Comment out the contents of your XAML file using standard XML comment syntax (wrap it with <!-- and -->), then rebuild your project to clear out all of the errors. You may also need to comment out some code in your .cs files temporarily to get it to build. Once you get it building, then you can go back and start uncommenting your XAML until you find the part that was breaking it.
Try it:
Open the Package Manager Console, put the follow line:
update-package -project your_pcl_project_name -reinstall

Custom control disappears from object browser

My question is on how custom controls should be updated.
I downloaded this owner drawn custom control, which I built, then copied the DLL to the Debug folder of the project and loaded it into the toolbox from there.
I decided to use this button on another project. I was mildly surprised to see the control was still in the toolbox but it seemed to work just fine. I decided to change this custom button's behavior. The button in the toolbox referenced the old version number. So I deleted it and loaded the newly rebuilt DLL.
Now come the problems. The first application--the one where the DLL was added to the toolbox from--still runs okay, but the second application is throwing errors, saying, Type 'CButtonLib.CButton' is not defined. When I add the button to a form, it appears okay. I can change its properties and it shows up in the code windows and in the object browser. But as soon as I try to run it and it throws the errors, it no longer appears in the object browser. References in the code window lose their intellisense.
Things I've tried include:
Copying the DLL to the project's debug and release folders and loading them into the toolbox from there.
Removing it from the toolbox altogether and just adding a reference then copying and pasting a button directly from the first project.
Copying in a form with a CButton on it from the first project.
Scouring the internet for answers
Swearing at the computer.
Nothing seems to work and I've now spent over a day trying to solve this.
I never did get to the bottom of this. In the end I simply had to recreate the entire custom control project using a different name. I suspect the way I added the original project to the toolbox of a different program – as opposed to adding it within the test project it came with – may have had something to do with it, but that's just a guess. Anyway, I can amend and update the new control without problem now, so all's well that ends well. :-)

Clicking and draggging a user control in VB .NET creates object reference error message

Failed to create component 'User Control 1'. the error message follows:
'System.NullReferenceException : Object reference not set to an instance of an object.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object Component, Object Value)
.............. etc..........
What should I do to fix this error?
When a User Control won't load into the Visual Studio designer here is what you need to do. These instruction are for vb.net project but c# should be similar. Also, before doing this close all open windows (or at least the source and designer files of the control you are working on.)
One last thing. The FIRST thing you should do is ensure that restarting visual studio doesn't fix the problem. If not you can try the steps that follow. These instructions assume that the errant user controls are in control library project in visual studio. If not you should be able to adjust the directions a bit to get it to work but it is much easier when the control is in its own project.
Do the following:
Make the control library your startup project.
Open the properties for the control library project and click on the debug tab.
Under Start Action click the Start external program option and browse to the Visual Studio executable.
NOTE: what this means is that when you run your solution it will fire up another instance of Visual Studio instead of actually running your solution. The First Instance of Visual Studion (INSTANCE_1) will "host" a second instance of visual studio (INSTANCE_2) when you run it.
Run your solution. INSTANCE_2 will load.
Switch back to INSTANCE_1.
In INSTANCE_1 hit CTRL-ALT-E. This will open up the exceptions dialog box. Check On the THROWN column checkbox next to Common Language Runtime Exceptions.
NOTE: This will ensure that INSTANCE_1 will BREAK at ANY runtime error even if it is hit in a try block.
Switch to INSTANCE_2. In Solution Explorer double-click to open the errant user control.
You should find that INSTANCE_1 OF Visual Studio should have stopped at the line of code that caused the designer to not load the control. Fix the code (which usually means testing for IsNot Nothing before references an object properties...but could mean other things.)
Also, sometimes I find that the control WILL load in INSTANCE_2 instead of breaking on an error in INSTANCE_1. In that case just stop debugging...close INSTANCE_2. Save/Restart INSTANCE_1 and your problem will often have gone away.
The lesson is this. User Control MUST be able to load/reference all objects and their members in order to load it into the designer. So for User Controls that will be placed onto other containers I will usually design events to notify the parent rather than trying to push objects into the child control.
Hope this helps for future reference on this old question.
Seth
Instead of the error occurring when you open up a form for editing, it sounds like this is occurring when you are already editing a form and adding new user controls. A CodeProject article that was previously mentioned shows what to do in the case of a form not loading correctly, rather than a specific user control.
Does your user control have any properties that map to custom objects (i.e. not Integer or String)? If so, the Form Designer will attempt to load your properties into the Property Editor. If showing the properties generates an error, the Form Designer will show that to you. I think this is what is happening with your user control.
If you could edit the question and add more information about the nature of the error (more of the error text), it would assist others in helping you better. Alternatively, see if you can find the property that might be causing the error (e.g. whether any property relies on a non-null value being set). You can also take a look at this MSDN article for tips on how to limit the control for just run-time.
Thanks, Seth, for this post! Your solution helped me nail down the error. The only thing I would add to this is that when "INSTANCE_2" loads, you may need to actually load the project file in INSTANCE_2. I needed to because I wasn't dealing with a control library, but instead had custom User Controls defined in the same project that the forms were located in. Once I loaded the project in INSTANCE_2, I opened the erring form and that caused INSTANCE_1 to pop up to the line of offending code in the User Control.
I have found that this error often occurs when control dlls are not building properly. 95% of the time this is remedied by simply restarting Visual Studio.