Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to VS Version 17.4.0 Preview 2.0 and I can't drop Chart on form #4

Closed
paul1956 opened this issue Sep 17, 2022 · 38 comments
Closed
Labels
bug Something isn't working designer Issue / question with new WinForms Designer. external issue An issue is caused by an external system and won't be fixed in this repo.

Comments

@paul1956
Copy link

image

@kirsan31
Copy link
Owner

kirsan31 commented Sep 17, 2022

Nice....
Unfortunately, I can't install V.S. preview, and even if I could, it wouldn't help :( We have nice situation here...

  • No designer sdk docs.
  • Designer sdk still in preview.
  • Preview of VS.

I will try to ask a question on this topic, but there is little chance of an answer, because still no response to the previous one...

-------------UPD-------------
Done: dotnet/winforms#7073 (comment)

@paul1956
Copy link
Author

Just an FYI the preview installs on a separate hive and runs parallel to your production version, I understand your doing it will not fix the issue.

@KlausLoeffelmann
Copy link

Can you try to attach a second version of VS both to the primary instance of VS and to the DesignToolsServer and Debug into it to see what exactly happens?

@paul1956
Copy link
Author

@KlausLoeffelmann I have VS attached to both of the processes and neither hit anything. Just this message pops up and if you hit OK nothing is changes in the Solution.
image

If you open Form1 of https://github.com/paul1956/CareLink/tree/DataVisualizationDesigner in designer, no Charts show up in Preview 2 where I could mostly design in Preview 1. In Preview 1, if you got too deep the properties in Scrollbar for example below can't be click on or exited.

Me.HomeTabChart.ChartAreas(NameOf(ChartArea)).AxisX.ScrollBar

image

The big black space on the left and behind and 100% are white Charts and Form1.Designer.vb has the correct add.

Me.SplitContainer3.Panel1.Controls.Add(Me.HomeTabChart)
Me.SplitContainer3.Panel2.Controls.Add(Me.HomeTabTimeInRangeChart)

@KlausLoeffelmann
Copy link

Did you change the exception filters to break on all exceptions?

image

@paul1956
Copy link
Author

@KlausLoeffelmann that helped

        public Assembly LoadFromAssemblyName(AssemblyName assemblyName)
        {
            if (assemblyName == null)
                throw new ArgumentNullException(nameof(assemblyName));

            // Attempt to load the assembly, using the same ordering as static load, in the current load context.
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
            return RuntimeAssembly.InternalLoad(assemblyName, ref stackMark, this);
        }

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.Windows.Forms.DataVisualization, Version=1.3.8296.30984, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Source=
StackTrace:

@paul1956
Copy link
Author

paul1956 commented Sep 21, 2022

@KlausLoeffelmann this version also deleted everything related to DataVisualiztion including all handler clauses and everything in designer file if you do any edits to the Form the Control was dropped on. This was fixed for the last several releases.

@paul1956
Copy link
Author

@KlausLoeffelmann do you know if this is fixed in Preview 3?

@KlausLoeffelmann
Copy link

I know too little about the approach.
What kind of Control Designer does it use?
Does it have dedicated Type Editors?
If yes, does it have Server and Client-versions for the Designer, and generate a NuGet Package which allows it to be loaded in the context of both the DesignToolsServer and VS?

I recently posted a few links to resources to check for best practices. The most important one is the preliminary (still in the making) description of the SDK: KlausLoeffelmann/NetControlDesigners#9.

@paul1956
Copy link
Author

@KlausLoeffelmann I can't answer those questions hopefully @kirsan31 can, I am just the user of the control. I do know that the Chart control worked in preview 1 (it appeared in toolbox, could be dropped on from, it displayed correctly and could be edited) and in Preview 2, existing charts don't display in designer and if anything changes on the form even unrelated to the Chart control everything about the chart is deleted from the design file except the Public Event declaration line. That seems like a major issue we have not seen since .Net 5 with Custom Controls.

@kirsan31
Copy link
Owner

@KlausLoeffelmann

I know too little about the approach.
What kind of Control Designer does it use?
Does it have dedicated Type Editors?
If yes, does it have Server and Client-versions for the Designer, and generate a NuGet Package which allows it to be loaded in the context of both the DesignToolsServer and VS?

It's very basic port. Added sdk, corrected namespaces, replaced ArrayEditor with Microsoft.DotNet.DesignTools.Editors.CollectionEditor, minor edits, commented out the rest. So no client-server designer of course.

@paul1956
Copy link
Author

No improvement in Preview 5
image

I am dropping the control on a TabPage or TableLayoutPanel.

@KlausLoeffelmann
Copy link

KlausLoeffelmann commented Oct 31, 2022

No. I debugged into that over the weekend, and it seems, the System.CodeDom assembly is loaded twice - once from the global installation, and once from the shadow cache. And then, on instantiation, the external Serializer uses the shadow cache one, while the Designer used the global one. Since their CodeBase is different, the types are considered different. We're still investigating, what broke to end up with this. (Also @Shyam-Gupta, @merriemcgaw FYI.)

We don't seem to have that problem, when the server-part of a multi targeted Control Designer comes from a NuGet. But I have yet to confirm that, although I am pretty sure, since the examples and templates also use base classes of the CodeDom Serializer, and they never explode. That could be a workaround, and it would make sense to go down that route anyway, since the Type Editors must be used in the context of VS, anyway.

@kirsan31
Copy link
Owner

@KlausLoeffelmann I think you are confusing this error with #5. You are talking about #5 bug and it's defiantly can be workaround by nuget (because it's 100% workaround by dll reference ).

And here we are talking about:

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.Windows.Forms.DataVisualization, Version=1.3.8296.30984, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

that was appeared in 17.4 preview 2.

Or is it something I don't understand?

@KlausLoeffelmann
Copy link

Hmm.
Yes, I am obviously confusing those, although the initial symptoms were the same, no?
Is that only when you drop it on a Tab Control, or is the drop target irrelevant?
Because when I workaround #5 I can drop just fine.

@kirsan31
Copy link
Owner

kirsan31 commented Oct 31, 2022

@KlausLoeffelmann

the initial symptoms were the same, no?

No, #5 was always here from first port (it was V.S. 17.0). And it was only with project reference (with dll reference all good). Naturally, it also works through Nuget.

And this (#4) is a new issue from 17.4 preview 2 only. And this is with dll reference - it basically can't load the dll (those. with a high degree of probability with nuget it will be the same).

Is that only when you drop it on a Tab Control, or is the drop target irrelevant?

I think with clean form the error will be the same... @paul1956 can you pls check it?

---------UPD---------

Yes with clean form the same error - can't even load dll.

Overall, with 17.4 we can't use designer at all any more :(

@paul1956
Copy link
Author

paul1956 commented Oct 31, 2022

I was able to create a new project and add the DataVisualization Project and then drop the control on a "form". But when I tried to do something with it (like delete it) I get below.
image
If I try to drop on a TableLayoutPanel I get the same error
image

Both these things worked prior to Preview 2.

@kirsan31
Copy link
Owner

kirsan31 commented Nov 1, 2022

@paul1956 both errors above are clearly #5. When your drag control on new clean form the reference to the control will be added by project. But we need to test dll reference scenario. It's my bad I did not describe exactly what needs to be done - sorry :(

See here: #4 (comment)

@paul1956
Copy link
Author

paul1956 commented Nov 1, 2022

If you mean

<ProjectReference Include="..\..\..\winforms-datavisualization\src\System.Windows.Forms.DataVisualization\ChartWin.csproj" />
 <ItemGroup>
   <Reference Include="System.Windows.Forms.DataVisualization">
     <HintPath>..\..\..\winforms-datavisualization\src\System.Windows.Forms.DataVisualization\bin\$(Configuration)\$(TargetFramework)\System.Windows.Forms.DataVisualization.dll</HintPath>
   </Reference>

They are both there

 </ItemGroup>

@kirsan31
Copy link
Owner

kirsan31 commented Nov 1, 2022

@paul1956 oh oh oh my bad again 🤦‍♂️🤦‍♂️🤦‍♂️

Yes they are both there and dll ref is commented out:

<ItemGroup>
<ProjectReference Include="..\src\System.Windows.Forms.DataVisualization\ChartWin.csproj" />
</ItemGroup>
<!--<ItemGroup>
<Reference Include="System.Windows.Forms.DataVisualization">
<HintPath>..\src\System.Windows.Forms.DataVisualization\bin\Debug\net6.0-windows\System.Windows.Forms.DataVisualization.dll</HintPath>
</Reference>
</ItemGroup>-->

For test we need to remove / comment out proj ref and uncomment dll ref:

<!--<ItemGroup>
  <ProjectReference Include="..\src\System.Windows.Forms.DataVisualization\ChartWin.csproj" />
</ItemGroup>-->

<ItemGroup>
  <Reference Include="System.Windows.Forms.DataVisualization">
    <HintPath>..\src\System.Windows.Forms.DataVisualization\bin\Debug\net6.0-windows\System.Windows.Forms.DataVisualization.dll</HintPath>
  </Reference>
</ItemGroup>

So, open DataViz.sln in latest V.S. preview, edit DesignerTest.csproj like above, save, rebuild and drag chart control from the toolbar on Form1 in the DesignerTest.csproj.

chartDesigner.mp4

@kirsan31 kirsan31 added designer Issue / question with new WinForms Designer. bug Something isn't working labels Nov 2, 2022
@kirsan31
Copy link
Owner

kirsan31 commented Nov 2, 2022

/cc @paul1956 pls check my previous post 🙏

@paul1956
Copy link
Author

paul1956 commented Nov 4, 2022

@kirsan31 same error.
image

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <!--<ItemGroup>
    <ProjectReference Include="..\src\System.Windows.Forms.DataVisualization\ChartWin.csproj" />
  </ItemGroup>-->

  <ItemGroup>
    <Reference Include="System.Windows.Forms.DataVisualization">
      <HintPath>..\src\System.Windows.Forms.DataVisualization\bin\Debug\net6.0-windows\System.Windows.Forms.DataVisualization.dll</HintPath>
    </Reference>
  </ItemGroup>

@kirsan31
Copy link
Owner

kirsan31 commented Nov 4, 2022

/cc @KlausLoeffelmann
I unsewered to you questions here.

In 17.4 we have #5 with proj reference (this bug exist in all VS versions), and #4 with dll reference (only 17.4 bug).
We need you help, because after 17.4 come out we will loss designer completely :(

@KlausLoeffelmann
Copy link

We're investigating. It seems, the System.CodeDom Assembly is loaded twice into the Designer process, but from a different CodeBase. In .NET, that is possible - a different CodeBase even with the same identity is considered different version-wise for the whole assembly. The Designer uses the global, the Serializer the one from the Shadow Cache, where the assembly shouldn't end up to begin with. We don't know yet exactly why that behaviour changed in later versions, but are working on that issue with top priority.

@kirsan31 kirsan31 added the external issue An issue is caused by an external system and won't be fixed in this repo. label Nov 4, 2022
@KlausLoeffelmann
Copy link

KlausLoeffelmann commented Nov 8, 2022

So...good news is, we are actively investigating. Not so good news is, it's not at all obvious right now why this is happening, but we're on it. It may take a while, though, so please stay tuned. It's planned to be addressed in 17.5, with a chance to be serviced in 17.4, depending on the extend and additional effects of the fix. @merriemcgaw FYI.

@kirsan31
Copy link
Owner

kirsan31 commented Nov 9, 2022

Thank you @KlausLoeffelmann. Then we stay at 17.3 and hope for servicing in 17.4...

@KlausLoeffelmann
Copy link

Quick additional questions in that context:

a) Can you have 17.3 and 17.4 on your test machine at the same time or does installing 17.4 also screwing up the scenario?

b) Is the Target Framework relevant (or installing additional .NET versions like 7.0 on that machine)?

Also @Shyam-Gupta for FYI to this.

@kirsan31
Copy link
Owner

kirsan31 commented Nov 9, 2022

@KlausLoeffelmann

a) Can you have 17.3 and 17.4 on your test machine at the same time or does installing 17.4 also screwing up the scenario?
b) Is the Target Framework relevant (or installing additional .NET versions like 7.0 on that machine)?

17.4 have released already, So I can't install it side by side with 17.3 :( Theoretically I can try with 17.5...
@paul1956 can you help here?

@paul1956
Copy link
Author

paul1956 commented Nov 9, 2022

I am running the preview released yesterday. But it broke ModVb so I might revert. What is the exact request?

@kirsan31
Copy link
Owner

kirsan31 commented Nov 9, 2022

I am running the preview released yesterday. But it broke ModVb so I might revert. What is the exact request?

Can you answer on @KlausLoeffelmann questions above?

@paul1956
Copy link
Author

I think you can only have 1 release version and 1 preview version.

@kirsan31
Copy link
Owner

@paul1956 I'll try to rephrase the question: after you installed 17.4 preview2 (in which the designer didn't work), did the designer still work in 17.3?

@paul1956
Copy link
Author

You don't think you can have the 2 full releases installed at the same time. I used GitHub to roll back and then stopped using designer.

@kirsan31
Copy link
Owner

@paul1956
image

On September 17 (when you post this issue) and then until 17.4 released - does designer worked in 17.3?

@KlausLoeffelmann
Copy link

KlausLoeffelmann commented Nov 10, 2022

I think you can only have 1 release version and 1 preview version.

You can have as many VS versions as you want. They all run in parallel just fine, you just need to give them different folder names.

Well, except if they don't, which shouldn't be happening. Hence my original question. 😄

@kirsan31
Copy link
Owner

kirsan31 commented Nov 10, 2022

@KlausLoeffelmann
I still don't understand how I can put the 17.4 release next to the 17.3 release 🤷‍♂️ but it's not that so important.

Only 17.3 installed, no .Net7 installed.
We have #5 and no #4 (this) on .Net6.

17.3 and 17.5p1 installed, .net7 installed (with 17.5p1).
In 17.3 we still have #5 and no #4 (this) on .Net6 and .Net7.
In 17.5p1 we still have #5 and #4 (this) on .Net6 and .Net7.

So on your questions regards #4 (because #5 is stably present everywhere):

a) Can you have 17.3 and 17.4 on your test machine at the same time or does installing 17.4 also screwing up the scenario?

17.3 working fine in any way and 17.4p2+ - NO.

b) Is the Target Framework relevant (or installing additional .NET versions like 7.0 on that machine)?

Installing additional .NET versions and/or change Target Framework doesn't break 17.3.


Most interesting part is that on this machine, after installing 17.5p1 commenting out this line:

// Add assignment statement for the DataSource property
System.CodeDom.CodeExpression targetObject =
base.SerializeToExpression(manager, value);

doesn't solve #5 any more 🙄 as I described here (bottom of the post).

Unfortunately I doesn't test this before 17.5p1 installation :(

@KlausLoeffelmann
Copy link

OK, that's helpful - thanks!
Again @Shyam-Gupta, @merriemcgaw for FYI.

@kirsan31
Copy link
Owner

Fixed in V.S. 17.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working designer Issue / question with new WinForms Designer. external issue An issue is caused by an external system and won't be fixed in this repo.
Projects
None yet
Development

No branches or pull requests

3 participants