angelsix / solidworks-api

C# SolidWorks API stuff
Other
274 stars 121 forks source link

Can't load the examples #30

Closed emersonbottero closed 6 years ago

emersonbottero commented 6 years ago

The example 1 loaded ok. the example 2 brings the error Attempt to load an assembly from a network location that would cause the assembly to be in safe mode in earlier versions of the .NET Framework. This version of the .NET Framework does not enable CAS policy by default, so this load can be dangerous. If it does not intend to place the assembly in a restricted area, enable the loadFromRemoteSources option. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. I added a configuration folder with

<?xml version="1.0" encoding="utf-8" ?>

But I can't test it with Solidworks 2017.

angelsix commented 6 years ago

Don't put the source code on a network drive. You cannot have dll's registered for COM when they are on a network drive

emersonbottero commented 6 years ago

I'm not in a network!!

angelsix commented 6 years ago

screenshot_1

Works fine. Must be your machine/network setup. Any more info?

brinkdinges commented 6 years ago

I just had a similar issue a few days ago with another project, maybe you are experiencing the same one.

In my case I downloaded DLLs from my own Google Drive. Windows wouldn't let me use those until I selected each one, opened up its properties in explorer and removed some safety flag. I don't know the exact name, but you'll recognize it when you see it.

emersonbottero commented 6 years ago

You are Right. You need to do it in every single dll. image

lowEagle commented 6 years ago

Sadly I have a very similar problem. The very first tutorial works well (written "by hand" simultanious to watching the youtube-video and also via import of the current directory copied from this repository).

However, as soon as I try to use your Framework (Tutorials 02-07) the addin will be registered (-> will be shown in the Addin-Menu) but not loaded. I tried to debug using Visual Studio and the very same break-point as shown in the 7th tutorial but the stop will never be reached.

I'm on the current version of Win10, x64. The files are stored locally and all libraries are manually set like @brinkdinges and @emersonbottero described in their previous posts. Unfortunately the project I'm working on forces me to use the Solidworks 2015-16 Edition. Anyways today I removed that and tried the current Student Edition (2017-18) instead - without any changes. I was hoping the use of the NuGet-Package will solve this issue but that won't work either.

Tomorrow I'm gonna try to register the compiled files on another computer. Any other suggestions?

emersonbottero commented 6 years ago

Have you change all referenced dll to the 2015-16?I think if you just overwrite the ones in the example you shouldn't had to change the code.

lowEagle commented 6 years ago

That was one of the first approaches, but currently it will lead to a mismatch between them and the ones includes by the NuGet-Packet (Translated Build-Error): Error CS1705 Assembly "AngelSix.SolidDna" with identity "AngelSix.SolidDna, Version=1.0.0.6, Culture=neutral, PublicKeyToken=null" uses "SolidWorks.Interop.swpublished, Version=26.0.1.1, Culture=neutral, PublicKeyToken=89a97bdc5284e6d8" with a higher version than the referenced assembly "SolidWorks.Interop.swpublished" with identity "SolidWorks.Interop.swpublished, Version=25.1.0.49, Culture=neutral, PublicKeyToken=89a97bdc5284e6d8". SolidDnaNuGet C:\Users\fabian\source\repos\07-SolidDnaNuGet\SolidDnaNuGet\SolidDnaIntegration.cs

All api-libraries are set to be not included (Embed interoptypes False).

I will do another test with the previous, non-NuGet, example. EDIT 1: As I have currently the 2017-2018 version installed and switching versions takes some time I tested this combination. So using the 2017 files works for the Tutorial no.2, but not for no.7. @angelsix is there a way to define the file that should be used by the Package or will that break to many things?

I'll give 2015-16 another try. The oldest privided files here are from 2016 but if those won't work I'm gonna try the ones provided by the installation. //EDIT 1

angelsix commented 6 years ago

There is no need to use older DLL files use the 2018 files they work for older versions.

Further more just open Visual Studio go to Tools Extensions and search for SolidDNA then install that. The go to Project New and you can see a SolidDNA project all setup for you https://youtu.be/Jhi1WFp47Qk

angelsix commented 6 years ago

For reference here is how to use NuGet package reference https://youtu.be/r8e3xFlmZ_o

lowEagle commented 6 years ago

First of all thank you @angelsix for the work you are doing.

I was able to get the past tutorials running using the 2018 DLL files and resetting some of the settings. However, the project based on your template still won't load.

I think I've set everything like desribed in your videos. The build works finde (except two warning regarding a versioning conflict of the files Microsoft.Extensions.Configuration.Abstractions and Microsoft.Extensions.Logging.Abstractions). The registration via your tools returns no error. I even tried registering manually via cmd-line. On SW startup the addin appears in the loading screen. Strangly there is no entry in the SW log: No error, no "LOAD_ADDIN". Like before it is not shown as activated in the addins panel and cannot be activated manuelly there.

For reference I took some screenshots that you can find attached. Maybe I'm overseeing something. The RestoreProjectStyle is set to PackageReference (which can now also be done globally in the NuGet section of the Visual Studio options. However, it has also been done in the .proj-file). The projectname shown in the screenshots is from my last attempt, using the exact same name like in your videos won't change anything. Message shown by your registration-program is the same as when registering all other projects; the last line says that the types have been registered successfully. SDNA_NuGet-Project_Screenshots.zip

brinkdinges commented 6 years ago

The last time I checked I also couldn't get the addin running when using the NuGet package. The then latest clone of the repo (9ff89d1772f2c294e0b188ff9f27628286c0e319) worked, which is why I didn't reopen my issue https://github.com/angelsix/solidworks-api/issues/31 immediately. But the NuGet package from the same date doesn't work.

angelsix commented 6 years ago

Watch the videos. If you are getting version issues you haven't edit your csproj file and changed the package restore style <RestoreProjectStyle>PackageReference</RestoreProjectStyle>