Skip to content

ModelDocExtension conflict #33

Description

@codestackdev

The following compile error is displayed when ModelDocExtension class is used explicitly:

error CS0433: The type 'ModelDocExtension' exists in both 'CodeStack.SwEx.AddIn, Version=0.8.1.0, Culture=neutral, PublicKeyToken=a46023996d4724e7' and 'SolidWorks.Interop.sldworks, Version=27.1.0.72, Culture=neutral, PublicKeyToken=7c4797c3e4eeac03'

ModelDocExtension modelDocExt2 = model.Extension;
var appPageSetup4 = modelDocExt2.AppPageSetup;

This only happens if variable of type ModelDocExtension is declared explicitly.

The are several workarounds available:

  1. Use IModelDocExtension instead of ModelDocExtension
IModelDocExtension modelDocExt1 = model.Extension;
var appPageSetup3 = modelDocExt1.AppPageSetup;
  1. Use var in C# to avoid explicit declaration
var modelDocExt = model.Extension;
var appPageSetup2 = modelDocExt.AppPageSetup;
  1. Do not declare the variable, but use Extension property of IModelDoc2
var appPageSetup1 = model.Extension.AppPageSetup;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions