I have a custom WPF UserControl in a DLL file. I access the UserControl from PowerBuilder via OleObject (COM). I'm trying to create an instance of the UserControl (code in .NET dll).
Everything works fine when I'm using it via COM from C++, but in PowerBuilder, I'm getting this error message:
Error Message
Can you help me to figure out, what the problem is?
Tell me, if you need some more information.
Thank you so much!!
Found the solution. :)
Had to load the assembly WPFToolkit.dll and System.Windows.Controls.DataVisualization.Toolkit.dll manually via Assembly.LoadFrom("...");
Now it works!
I think you will have to load all assemblies which contain custom classes which are used in the xaml this way.
Related
I am trying to replicate this LiveCharts GeoMap in WPF but having an issue with the source file of my xml map :-
https://lvcharts.net/App/examples/v1/wpf/GeoHeatMap
I can produce it fine under WinForms but need to create a working version under WPF, if anyone can assist or point me in the right direction, I’m sure it’s something obvious that I’m missing?
The error I get states that the source path for my xml file doesn’t exist, when it clearly does.
If I follow the example, I create a user control, copy in the xaml plus the code behind, as per the website, then in my main window xaml, make reference to the user control. It’s at this point that it can’t load my main window as it can’t find the source file that I have referenced in my user control. In winforms I can reference it using source=#“c:\temp\world.xml” in code behind but cant do that in the xaml either. Where am I going wrong! Thanks
I had the same issue. It seems as if the NuGet package is outdated (2017).
Try to clone the LiveCharts repository and build it yourself.
In the properties of the XML file:
set Compile Action to none
In the Copy to directory:
set it to Copy Always
My Visual Studio is in Portuguese, but I think you'll get the idea.
If you're interested, there are detailed maps for each country/region; go to https://github.com/Live-Charts/Live-Maps.
As the title suggests, this error is thrown by the designer, which means the designer can't display my UserControl correctly which in turn means I can't navigate smoothly from element to element in this UserControl to make modification. Really annoying.
XXX is the name of my UserControl, while the URI YYY is actually XXX's path. So I don't know understand it can't find itself as resource. I googled this error, but most of them happened in the runtime. In my case it doesn't happen at all when I execute it. The description of this error is really not explanatory enough, because I am not sure who in the CLR is loading the file itself as a resource.
Another thing might be worth mentioning is, this error only happens after I build my application project, which the error UserControl resides in. After I click to clean the project, the designer can display the whole stuff (but obviously I can't clean the project every time before I make any change, since the building takes time)
It is possible that the control's .g.cs or .g.i.cs file has been corrupted. Try to clean, close visual studio and restart it. I think that helped for me in several cases especially when I copy paste controls from one solution to another.
Just delete subfolders in
%LOCALAPPDATA%\Microsoft\VisualStudio\12.0\Designer\ShadowCache
If you refactor a UserControl down a lower level project that the UserControl was previously referencing then you will see this error.
Removing the assembly reference from the namespace fixes the issue.
<UserControl xmlns:ui="clr-namespace:MyCompany.Core.UI;assembly=MyCompany.Core.UI"
should be
<UserControl xmlns:ui="clr-namespace:MyCompany.Core.UI"
The designer is not smart enough to highlight this.
I ran into the same issue, it compiled and ran fine, but the XAML editor/Designer complained. In my case, I found the solution to be that my user control was declared within a namespace in the XAML (x:Class="myNamespace.myUserControl") but not in the code behind. Adding the namespace declaration in the code behind solved my issue.
There is a possibility to debug Visual Studio Designer in the second attached Visual Studio.
See How to troubleshoot and debug Visual Studio design mode errors for details.
To display the UserControl, the designer has to instantiate the user control. Look for possible Null Reference Exceptions.
In my case the user control had an NRE due to a dependency not being injected. I added handling for the NRE and no more issue.
I'm improving an existent WPF project with a TCP/IP protocol that sends and receive small objects. I'm using Visual Studio 10 but I'm stuck.
I'm using BinaryFormatter to serialize the objects and until I used to send and receive with two classes in the same project I had no problem, but when I separated listener and sender (TCPListener and TCPCLient) on runtime i had this error:
"Can't find Assembly 'ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'".
Googling I found out that the problem could be solved creating an external dll called from main program, but I don't know how to pass the MainWindow to the dll because the library not even can find WPF types (such as MainWindow, Combobox or Textbox)
Can you help me with this dll problem or do you have any ideas to solve the assembly reference problem?
First of all, you shouldn't pass the MainWindow to a class you intend to serialize. This data class should actually not have any dependencies on the GUI. In fact, if you want to serialize a class, its public interface should in my opinion only contain primitive types or classes defined in the same assembly.
However, for a quick fix, and if you don't want to rewrite your project completely, I found that the easiest way to get the dependencies for a WPF library right was to start a new WPF application project and then change its project type to WPF Class library in the application tab of the project properties.
I'm having an issue where silverlight doesn't recognise custom controls or resources.
I include the namespace and intelisense recognises the item, the application builds fine and runs fine however the designer throws the following error.
The type 'x' was not found. Verify that you are not missing an assembly reference
and that all referenced assemblies have been built.
Usually I'm able to sort out the issue by performing a clean/rebuild of the project. however recently this route has been unable to resolve the issue.
Is this a known issue with the Visual Studio designer? are there any fixes/work arounds out there?
Thanks
EDIT:
I'm using the following declaration:
xmlns:converters="clr-namespace:x.Classes.Converters"
and referencing the control using the following:
<converters:ReportTypeImageConverter x:Name="ReportTypeImage"/>
Restarted visual studio this morning when I logged in and now its recognising the controls, which means I can use the designer again.
Try to go to your Project Properties and put some Reference Paths(folders where you .dll are)
Hope it Helps
i have a project that i am doing and i need to share the code between silverlight and WPF Assembly problem is that even though the wpf assembly is the owner of that file
and the silverlight assembly only has a link to the file, all of the build actions are page everything is correct. if i make the silverlight assembly the owner then silverlight works and wpf doesnt, and currently with wpf being the owner i dont get any errors at all it just never styles the control like it cannot find it..
Note: both projects exists in the same solution.
this scenario builds and runs fine
wpf project
|__Themes
|__Generic.xaml
|__SomeControl.cs
this scenario builds and runs but will not display the control
if i change them from linked to normal it will work fine.
i just want to share this source code and not have multiple versions of the same file floating around.
SilverlightProject
|__Themes
|__"Linked"Generic.xaml
|__"Linked"SomeControl.cs
sorry for my corny Tree view representation
+++++++ UPDATE +++++++++
i have noticed when using any linked file regardless of if it is silverlight or WPF
the link file will not build into the Themes folder in the resource only the root.
i used reflector to see where my resources ended up after compilation of the assembly including the linked file and they ended up in the root , so with that being said. is there a way to prevent this or a fix for this if this is indeed non intended behavior .
i would really love to get this figured out as it has been driving me insane for a while now.
Silverlight XAML and WPF XAML do not have the same namespace - so they aren't directly reusable.
My mistake - you're right - now with Silverlight 3 the namespaces are the same:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml
What is the Build Action in the Property Pane for the XAML?