ComponentFactory / Krypton

Krypton WinForms components for .NET
BSD 3-Clause "New" or "Revised" License
1.87k stars 686 forks source link

Build this repo or nuget packate #56

Open Defkon1 opened 7 years ago

Defkon1 commented 7 years ago

Is it better to download/fork/build this project and add the DLLs to my project or to add KS from a nuget packages like https://www.nuget.org/packages/KryptonSuite47/ ?

JoeRecursionJoe commented 7 years ago

I tried both Nuget packages and received a security error something like "attempt by security transparent method componentfactory.krypton to call native code through method...".

The Nuget Krypton dlls version are 4.7 and this repo dll version is 4.5 so I'm not sure if someone forked it and modified it to get the Nuget.

I would stay with this repo as it comes from the author...

PWagner1 commented 7 years ago

As the author of the Nuget packages, I would suggest to download/build and test the original repo. There is a odd bug with the Nuget packages, whereby it will not work unless you have the original DLLs working. This is something I cannot resolve, as it has something to do with how the original author structured the code.

However, it does work, as I had fully tested the new DLLs before publishing. The only change I had made was to re-target the frameworks to 4.6.2 and 4.7. I also added the DPI awareness feature in version 4.7, though I'm not sure that this is working. Hope this helps.

JoeRecursionJoe commented 7 years ago

Thanks. Could you elaborate though on , “it will not work unless you have the original dlls working” because I had the original dlls from this repo installed, but still had the Nuget the error.

Could the Nuget error possibly be related to changing the frameworks to 4.6.2 and 4.7?

PWagner1 commented 7 years ago

Hi @JoeRecursionJoe

Thanks for your reply. Yes I can explain why it happens, but I need to write it up first, as it's quite long. The reason for the disparity in version numbers is an easy reference to the frameworks that they were compiled for. The short answer is yes they do work, but you need to put in some extra work to get them working. I will post a more detailed explanation on this thread either later today or tomorrow.

PWagner1 commented 7 years ago

Hi @Defkon1 & @JoeRecursionJoe

After a bit of testing, I have discovered that the DLLs downloaded by the Nuget packages may need to be re-registered into your Global Assembly Cache. These DLLs can also be temperamental sometimes.

To do this, simply build your project, go to your \bin folder, copy the krypton DLLs into another folder i.e. C:\Developer DLLs\Krypton Suite\Versions\version number. Find a copy of gacutil.exe on your computer, copy/paste it into the mentioned folder (you may need to download/install the latest stable Windows SDK to find this binary).

Open up notepad and paste the following into it:-

gacutil.exe -i "ComponentFactory.Krypton.Design.dll"
gacutil.exe -i "ComponentFactory.Krypton.Docking.dll"
gacutil.exe -i "ComponentFactory.Krypton.Navigator.dll"
gacutil.exe -i "ComponentFactory.Krypton.Ribbon.dll"
gacutil.exe -i "ComponentFactory.Krypton.Toolkit.dll"
gacutil.exe -i "ComponentFactory.Krypton.Workspace.dll"

::REBOOT:
shutdown.exe /r /t 00

Save the file as RegisterToGAC.bat and place it into the directory where you have stored the DLLs and gacutil.exe. Next open a new command prompt window with administrative privileges, navigate to the directory you have stored your files, and then run RegisterToGAC.bat.

PLEASE ENSURE YOU HAVE SAVED ANY IMPORTANT WORK BEFORE RUNNING THIS BATCH FILE, AS YOUR SYSTEM WILL REBOOT AND I WILL NOT BE RESPONSIBLE FOR ANY LOSS OF DATA. YOU DO THIS AT YOUR OWN RISK!!!

NOTE: It may take several reboots to register the DLLs into your Global Assembly Cache! Open your project, and add the DLLs to your toolbox. Hopefully this should work! On several occasions, I have noticed a Heisenbug effect.

Alternatively, you can download the original repo, and re-target frameworks/rebuild/re-register yourself.

Please note that the 4.6.2 version will run on Windows 7 and above, whereas version 4.7 will ONLY run on Windows 10 Creators Update (1703) and above!

I hope this helps!

JoeRecursionJoe commented 7 years ago

Great @Wagnerp ! I am assuming you would only have to register to GAC only once?

Also I've never created a Nuget package, where do you go to find out how?

PWagner1 commented 7 years ago

Hi @JoeRecursionJoe

I have found that sometimes you may need to run the script a few times before it finally 'clicks' into place, or even weirder, you can only use it after 12 hours of running the script, and shutting down the system before booting it up again.

As for creating Nuget packages, I use a tool called NuGetPackageExplorer available from https://github.com/NuGetPackageExplorer/NuGetPackageExplorer

JoeRecursionJoe commented 7 years ago

Cool thanks @Wagnerp I'll check it out...

PWagner1 commented 7 years ago

@JoeRecursionJoe If it doesn't work out for you, then I would download the original repo, and re-target frameworks/rebuild/re-register the binaries.

MGRussell commented 7 years ago

I'd recommend downloading the repo. It builds with 0 modifications in Visual Studio 2017. The one issue is that you need to run the instance of visual studio as an administrator since the build automatically adds the generated DLLs to the global assembly cache using gacutil.exe, which requires elevation.

More importantly, the repo contains extensive examples and documentation you would not get with just a nuget of the dlls. The code itself is also very well documented and also works as a resource.

Zyxious commented 7 years ago

I also had problem using the nuget packages in VS.NET 2017 with runtime 4.6.2. Using the error message I think I figure out the problem.

The Krypton suite is developed for .NET 2 and not adapted to .NET 4. The code access security has been changed between the .NET versions. Read more on this here: https://docs.microsoft.com/en-us/dotnet/framework/misc/security-transparent-code-level-1

I'm able to use the Krypton Suite without registering the dll:s to the GAC by doing these changes:

@Wagnerp, maybe you could do these changes and update the nuget packages?

PWagner1 commented 7 years ago

@Zyxious

Of course I'll see what I can do. Is it just adding the [assembly: SecurityRules(SecurityRuleSet.Level1)] into all AssemblyInfo.cs files or is there more to do? I have got version 4.7 working in my environment, I may remove that package, as everyone seems to have issues with it.

UPDATE: As of Friday 25th August 2017, the 4.7 version WILL NO LONGER be available to download on NuGet until further notice. If you need it to work with .NET 4.7, then you will have to re-target/compile the source code yourself in a administrator environment of Visual Studio.

Zyxious commented 7 years ago

@Wagnerp

Yes, I opened the Krypton Components\Krypton Components Suite 2015.sln. Changed target framework in all projects of the solution to (in my case) .NET 4.6.2. and I also added [assembly: SecurityRules(SecurityRuleSet.Level1)] to the assemblyinfo.cs file in each project.

I have done no more modifications.

PWagner1 commented 7 years ago

Hi Andy (@Zyxious),

Thanks for the reply, I will work on it today. Please note that the updated section of my previous comment is more aimed at the readers of this thread and not directly aimed at you.

Peter

PWagner1 commented 7 years ago

I've just created a new version of the Nuget package which will be uploaded shortly. This includes the fixes as suggested by @Zyxious. I've also included some other helpful files, which will be added to a new folder labeled 'Extras' in your project's bin directory. As a result, the file is now 66 MB with these extra files.

I hope to upload a .NET 4.7 version soon.

Smurf-IV commented 6 years ago

Is this the new download ? https://www.nuget.org/packages/KryptonSuite47b/

PWagner1 commented 6 years ago

Hi @Smurf-IV

Yes it is

Smurf-IV commented 6 years ago

@Wagnerp It appears that the designer dll does not work within Studio. This may be because you have not updated the version number usage in the actual implementation dll's e.g. If the designer dll has [assembly: AssemblyVersion("4.7.1.0")]

then the KryptonButton class will need to have it's attribute line changed to

[Designer("ComponentFactory.Krypton.Toolkit.KryptonButtonDesigner, ComponentFactory.Krypton.Design, Version=4.7.1.0, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e")]

Smurf-IV commented 6 years ago

@Wagnerp, where is your updated fork for the .Net 4.7 codebase. I have the same done, but with .net47 lync statements, syntactic sugar etc. added (i.e. I've let ReSharper loose on the code base). I would like to combine and then for you to review and nuget it out.

PWagner1 commented 6 years ago

@Smurf-IV Will upload it later today. Please check back later on my profile to submit a merge.

EDIT: It's now uploaded to submit merges.

oghenez commented 5 years ago

Can i recompile this for .Net 2.0?

PWagner1 commented 5 years ago

@oghenez

Yes you can, just change the target framework back to .NET 2.0.