document doc causes Common L. runtime error when using in UC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I create a few custom UserControls modules that call on .net api. the point of those custom UCs was to populate a parent UC.
That way, I'd manage my code easier, and create objects that could be reused later on. the problems appear when I try using Visual Studio Designer Toolbox to add the said modules to a parent UC. I get a "common language runtime error" that always originates from
"Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;"
to illustrate that its not my coding error, I've tried testing it in a stand alone app, and behold, same error appears again.
so far I've had no problems running api commands from User Controls, but this is the first time I try having a childUC with api commands,
and I'm unsure if thats the cause of the problem.
I've attached a screenshot of my test app: the error appears as soon as I try to add the child control to the parent UC. (myCommands, and myPlugin are unaltered).
code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Autodesk.AutoCAD.ApplicationServices; namespace why_no_work { public partial class child : UserControl { public child() { InitializeComponent(); } Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; } }
I tried cleaning the solution, rebuilding the solution, tried disableing optimize code,...
using Acad2017/VS2015/Win10/x64