# Can't run .NET 6 console app due to missing System.Drawing package

**URL:** <https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313>\
**Category:** AlterNET Studio Support\
**Tags:** scripter\
**Created:** [July 4, 2022, 10:35pm UTC](https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313 "2022-07-04T22:35:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrewS](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/a/606060/32.png) [@AndrewS](https://forum.alternetsoft.com/u/AndrewS)\
**Post date:** [July 4, 2022, 10:35pm UTC](https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313/1 "2022-07-04T22:35:20Z")

</div>

Simple console app that references Alternet.Studio.Scripter.TypeScript version 8.0.6 in order to load and run JavaScript files. Builds successfully but when I run it I get this exception:

```auto
Unhandled exception. System.TypeInitializationException: The type initializer for 'Alternet.Common.TypeScript.TypeScriptProject' threw an exception.
--> System.IO.FileLoadException: Could not load file or assembly 'System.Drawing, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

```

Is this due to the dependency on WinForms as mentioned in [Is there an example running on .Net Core?](https://forum.alternetsoft.com/t/is-there-an-example-running-on-net-core/80)? If so any ETA for a fix for this?

---

<div class="post-metadata">

**Author:** ![yevgeni.zolotko](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/yevgeni.zolotko/32/25_2.png) [@yevgeni.zolotko](https://forum.alternetsoft.com/u/yevgeni.zolotko)\
**Post date:** [July 6, 2022, 12:22pm UTC](https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313/2 "2022-07-06T12:22:38Z")

</div>

I created a simple .NET 6 console application which evaluates an expression using the Scripter for TypeScript, and it seems to work fine. You can download the project from [here](https://alternetsoftware.blob.core.windows.net/forum/SimpleTSScripterConsoleApp.zip).  
I expect that you are experiencing this issue with some other test code. Could you please make a small sample project that illustrates the issue and send it to us?

---

<div class="post-metadata">

**Author:** ![AndrewS](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/a/606060/32.png) [@AndrewS](https://forum.alternetsoft.com/u/AndrewS)\
**Post date:** [July 7, 2022, 4:33am UTC](https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313/3 "2022-07-07T04:33:42Z")

</div>

I managed to reproduce it using your sample app. Add this line of code after the using statement:

`string defPath = Alternet.Common.TypeScript.TypeScriptProject.DefaultProject.AutoGeneratedTypeDefinitionsPath;`

Then run the app and you will get the same error I am seeing.

---

<div class="post-metadata">

**Author:** ![yevgeni.zolotko](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/yevgeni.zolotko/32/25_2.png) [@yevgeni.zolotko](https://forum.alternetsoft.com/u/yevgeni.zolotko)\
**Post date:** [July 7, 2022, 11:39am UTC](https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313/4 "2022-07-07T11:39:32Z")

</div>

Thank you for your reply.  
You can add the following lines to your .csproj file as a workaround:

```auto
    <UseWindowsForms>True</UseWindowsForms>
    <TargetFramework>net6.0-windows</TargetFramework>

```

This is because the Scripter uses some types from Windows Forms. Does this solution work for you?

---

<div class="post-metadata">

**Author:** ![AndrewS](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/a/606060/32.png) [@AndrewS](https://forum.alternetsoft.com/u/AndrewS)\
**Post date:** [July 8, 2022, 6:09am UTC](https://forum.alternetsoft.com/t/cant-run-net-6-console-app-due-to-missing-system-drawing-package/313/5 "2022-07-08T06:09:48Z")

</div>

Yes, that fixed my problem, thanks!
