.NET

Reply
Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 1 of 7 (856 Views)

Plugin with WPF-window and XAML-assembly binding dont find the assembly

856 Views, 6 Replies
04-20-2012 01:57 AM

Hello,

 

i have a plugin-dll with WPF-Window. This window binding on xaml other assemblys (for MVVM) by xmlns:...

By runtime dont find the plugindll the "xmlns:..." assemblys, but the normal reference-Assembly is found.

I have set the supportpath to dll.

 

Why dot find acad the xmlns: assemblys?

 

(Using ACAD 2011 and VS2010)

 

regards

Mario

Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 2 of 7 (807 Views)

Re: Plugin with WPF-window and XAML-assembly binding dont find the assembly

05-01-2012 10:25 AM in reply to: mario.rosenbohm

a WPF form is rendered in the context of an exe, so all in xaml referenced assemblies either installed in the GAC or located in the directory of the executable.

 

An alternative to the exe directory is the manipulation of acad.exe.config, more precisely the privatePath. At the indicated there folder (below the exe directory) is searched for assemblies. This gives you at least own directory for its assemblies / dlls

 

<configuration>
...
<runtime>
<assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">
<probingprivatePath="Fdo\bin;Plugins\Workflow\Activities;Plugins\myownplugins"/>
</assemblyBinding>
</runtime>
</configuration>

 

 regards Mario

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 3 of 7 (719 Views)

Re: Plugin with WPF-window and XAML-assembly binding dont find the assembly

08-25-2012 02:04 PM in reply to: mario.rosenbohm

hi mario, thanks for sharing this, much appreciated.

i think i've been running into the same problem, but to clarify:

 

a new plugin project gives me, in 'MyCommands.vb' an assambly with namespace and class 'MyCommands' with the different commandmethod subs to chose from. 'add new item' to the project, say a wpf window, then adds 'Window1.xaml' to the project, as seen in the solution explorer, plus a sub to that containing the code-behind.

 

i want to create a generic binding from window to a collection object, say 'Collection1', for later use. therefore i create a collection class in the plugin's namespace (next to the class 'MyCommands' in 'MyCommands.vb'); in window1's xaml a namespace import and, as a resource, an instance of the binding source with a key:

 

<Window x:Class="Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:local="clr-namespace:AutoCAD_VB_plug_in4"

Title="Window1" Height="300" Width="300">

<Grid>

 <Grid.Resources>

  <local:Collection1 x:Key="C1"/>

 </Grid.Resources>

</Grid>

</Window>

 

it's the reference to Collection1 where i'm stuck: although intelisense offers it (and MyCommands) when '<local:' is typed, it instantly flags it as an error, that the type wasn't found. and if it's not obvious, i'm not at all clear how to make the binding work, ie be able to fill the collection from code so that it's available to the form and its code-behind.

could you possibly say if this is what you experienced and how you addressed it?

 

many thanks

 

Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 4 of 7 (682 Views)

Re: Plugin with WPF-window and XAML-assembly binding dont find the assembly

08-27-2012 01:59 AM in reply to: FFlix

Hello FFlix,

 


a WPF form is rendered in the context of an exe, so all in xaml referenced assemblies either installed in the GAC or located in the directory of the executable.


It is also when the Command/Plugin-Dll contains the XAML!

 

xmlns:local="clr-namespace:AutoCAD_VB_plug_in4"
...
  <local:Collection1 x:Key="C1"/>

 ... Use the XAML-Binding on rendering-Time. This is absolutely detached from the IDE to look (...although intelisense offers...)

 

When AutoCAD rendering the XAML will binding the "clr-namespace:AutoCAD_VB_plug_in4". But search points

for this DLL is only in GAC, acad.exe-path and the paths in

...

..probing privatePath="Fdo\bin;Plugins\Workflow\Activities;Plugins\myownplugins"/..

...

Acad.exe search newer in your applicationpath!

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 5 of 7 (676 Views)

Re: Plugin with WPF-window and XAML-assembly binding dont find the assembly

08-27-2012 04:10 AM in reply to: mario.rosenbohm

hi mario, many thanks for your reply.

 

IF i understand this right then:

 

runtime attempts bind the wpf Window1 in the context of the calling assembly's application, ie acad;

acad points runtime to either its exe file directory or its gac;

that is NOT where the plugin's source Collection1 is, therefore the reference is unresolved (-but that's runtime, how does the debugger know about it when it's flagged as 'type was not found'?);

however, runtime does check the acad configuration file in the exe directory;

and by inserting

<assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">

   <probingprivatePath="filepathtoplugin"/>

</assemblyBinding>

into the <runtime> tag, runtime is directed to the plugin's source Collection1.

 

ignoring my doubtful question, that would mean that a plugin with a wpf binding depends on the modification of the acad config file, which is machine specific, so the plugin can't otherwise be distributed. am i getting any of this right?

 

Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 6 of 7 (672 Views)

Re: Plugin with WPF-window and XAML-assembly binding dont find the assembly

08-27-2012 05:05 AM in reply to: FFlix

Hello FFlix,

 

I also sat there and knew nothing ;-)

 

The plugin-management in acad2011 is "very useful".

 

The manipulation for acad.exe.config i have a litle exe i this calling in the install/deinstall.

 

File see here

 

regards Mario

 

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 7 of 7 (638 Views)

Re: Plugin with WPF-window and XAML-assembly binding dont find the assembly

08-29-2012 07:26 AM in reply to: mario.rosenbohm

hi mario, even though eventually i took another route, your feedback has been helpful.

 

looking at my own post, i now think that (in this case)

 

1. importing a namespace is nonsense, window1 xaml binds to window1 code-behind;

2. the binding source can simply be specified by adding 'DataContext="{Binding RelativeSource={RelativeSource Mode=Self}" ' to <window>, and 'ItemsSource="{Binding Path=...}" ' to <user control> in the xaml declaration.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!