Hi,
I have created my GUID, and I'm trying to compile my code.
But always is the same error message:
Error 1 The type 'System.Windows.Interop.IWin32Window' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. C:\C#_Projects\test8\PreviewBox\PreviewBox\Class1.cs 30 20 PreviewBox
I have MVS2010 and AutoCAD2013.
Net framework 4.0.
What I should to do?
regards
Hi,
the message shows you:
>> You must add a reference to assembly 'PresentationCore [...]
have you done that?
- alfred -
Hmm...
no, I did not...
after the addition, works 🙂
I had to also add "static" in this line:
static Guid guid = new Guid("2919D05C-3A64-4098-B465-FCE445CBD1C7");
PaletteSet myPal = new PaletteSet("commandname", guid);
I test this example:
http://blog.smitec.net/posts/autocad-dwg-preview-control/
code:
https://github.com/smitec/AutocadPreviewBox
thank you alfred.
Hmm...
this code is correctly compiled, but if I want to add DWG file, AutoCAD generates an error.
What is wrong?
regards
Hi,
what I see when I open your project (have not started it at all):
Interesting would be to see what message you get? Upload a screenshot from this message.
- alfred -
Where is this position?
OK.
I've added acad.exe.
After Debug (F5), AutoCAD2013 run and show me the error message:
Application does not support just-in-time (JIT)
debugging. See the end of this message for details.
************** Exception Text **************
System.InvalidCastException: Unable to cast object of type 'Autodesk.AutoCAD.LivePreview.PreviewRuleProvider' to type 'Autodesk.AutoCAD.Internal.IPreviewContextProvider'.
at Autodesk.AutoCAD.LivePreview.PreviewContextService.LoadContext()
at Autodesk.AutoCAD.LivePreview.PreviewContextService.get_ContextProvider()
at Autodesk.AutoCAD.LivePreview.PreviewContextManager.OnIdleInitialize(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at Autodesk.AutoCAD.ApplicationServices.Core.Application.OnIdle()
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.296 (RTMGDR.030319-2900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
Acdbmgd
Assembly Version: 19.0.0.0
Win32 Version: 19.0.55.0.0
CodeBase: file:///C:/Program%20Files/Autodesk/AutoCAD%202013/AcdbMgd.DLL
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.296 built by: RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
I load my DLL (netload) and write PREV.
I see My Palette.
I write LDPRV, and error.
regards
OK. I have found this "local copy".
I changed to "False".
Now, F5 (Debbug) doesn't generate an error, but still is when I write LDPRV.
Hi,
>> Now, F5 (Debbug) doesn't generate an error, but still is when I write LDPRV.
Ok, then next step is to tell the debugger to stop on all errors. Do that in Visual-Studio ==> pull-down-menu "debug" ==> item "exceptions" (hope that the translation from my German version is ok for that words) and within this dialog check "Common Language Runtime Exceptions".
Now exceptions raised during code will break the debugger and show you the position where the exception occured.
- alfred -
It's done.
I have found description this exception:
Do you have any idea what now?
regards
Hi,
myPreviewBox is never set to an object (never instanciated) as this.Preview is never started.
- alfred -
Hmm...
in an example was:
/// <summary>
/// Instance of the Preview box
/// </summary>
PreviewBox myPreviewBox;
I have changed to:
PreviewBox myPreviewBox = new PreviewBox();
and now, the error is here:
maybe this example is incorrect and I never won't run this project?...
regards
Hi,
does that happen with all drawings? Have you set your AutoCAD to "not save the thumbnails"?
The error seems to raise when the line above does not return a valid object (variable preview). So either there is no image in the file or the function does not return a bitmap.
(have not tried your code, so that's just guessing)
- alfred -
When I comment this line:
//grab the thumbnail bitmap and get rid of the white background
System.Drawing.Bitmap preview = dbb.ThumbnailBitmap;
//preview.MakeTransparent(System.Drawing.Color.White);
program run propertly, but view nothing in "My Palette"...
I added Alert in this place:
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("\nAlert " + fn.StringResult);
//use the loaded dwg file to update the preview box
myPreviewBox.load_file_preview(fn.StringResult);
and show me path to my DWG file - is correct, eg. "c:\Blocks\My_blok.dwg".
"does that happen with all drawings?" - Yes.
Have you set your AutoCAD to "not save the thumbnails"? - where can I set this?
regards
Hi,
>> Have you set your AutoCAD to "not save the thumbnails"? - where can I set this?
Command _OPTIONS ==> tab "Open and Save" ==> button "Thumbnail Preview Settings"
- alfred -
Can't find what you're looking for? Ask the community or share your knowledge.