C
C#7mo ago
stigzler

✅ Could not load file or assembly or one of its dependencies at runtime despite being present

I'm developing a Visual Studio Extension in .net Framework. I'm getting this attached ulcer-inducing error at runtime. I've downloaded the most recent version of Syncfusion.Edit.WPF via NuGet and this also downloads its dependencies (listed here). It's clearly in the Project references (attached) and also in the build directory (attached). The dlls are also the right file version (matching those in nuget). Lastly, I used this in another Extension project with exactly the same libraries/references and it works fine. So I think it's something to do with my Solution/Project or a .net idiosyncrasy. The xaml:
<syncfusion:EditControl Grid.Row="4" Text="Edit Control" Height="100" />
<syncfusion:EditControl Grid.Row="4" Text="Edit Control" Height="100" />
(no intellisense errors) I've tried all the normal: deleting obj/bin folder, cleaning the solution, restarting VS. It persists. Any ideas? Github Repo: https://github.com/stigzler/VisGist
GitHub
GitHub - stigzler/VisGist
Contribute to stigzler/VisGist development by creating an account on GitHub.
No description
No description
No description
49 Replies
SpReeD
SpReeD7mo ago
It's working ¯\_(ツ)_/¯
No description
stigzler
stigzlerOP7mo ago
you've just built that on your pc?
SpReeD
SpReeD7mo ago
Yep
stigzler
stigzlerOP7mo ago
Yep - it builds, but you get the error at runtime
SpReeD
SpReeD7mo ago
Ah, I see, it happens when you try to open the window Have you tried adding them into the AssemblyInfo.cs?
stigzler
stigzlerOP7mo ago
Well - thanks for taking the time to check, but not sure how that moves me on really yeah - I'm not sure Extensions have that - couldn't see it in the folder I did check the csproj file - all references to the right versions wait
<PackageReference Include="Syncfusion.Edit.WPF">
<Version>25.1.42</Version>
</PackageReference>
<PackageReference Include="Syncfusion.SfSkinManager.WPF">
<Version>25.1.42</Version>
</PackageReference>
<PackageReference Include="Syncfusion.Themes.MaterialDark.WPF">
<Version>25.1.42</Version>
</PackageReference>
<PackageReference Include="Syncfusion.Themes.MaterialLight.WPF">
<Version>25.1.42</Version>
<PackageReference Include="Syncfusion.Edit.WPF">
<Version>25.1.42</Version>
</PackageReference>
<PackageReference Include="Syncfusion.SfSkinManager.WPF">
<Version>25.1.42</Version>
</PackageReference>
<PackageReference Include="Syncfusion.Themes.MaterialDark.WPF">
<Version>25.1.42</Version>
</PackageReference>
<PackageReference Include="Syncfusion.Themes.MaterialLight.WPF">
<Version>25.1.42</Version>
SHould this also be refencing Syncfusion.GridCommon.WPF etc? Ah no - just checked the other working extension which uses the control and they're not there God this is frustrating
SpReeD
SpReeD7mo ago
Nah, it's working, you just need to give VS a hint about the packages Not only the top-level, but also the transitive packages as well
stigzler
stigzlerOP7mo ago
how do i do that?
SpReeD
SpReeD7mo ago
I'm on it, sec
stigzler
stigzlerOP7mo ago
Ok - thanks
SpReeD
SpReeD7mo ago
Btw. you have binding errors
stigzler
stigzlerOP7mo ago
the "hello world" one?
SpReeD
SpReeD7mo ago
Not only
SpReeD
SpReeD7mo ago
No description
SpReeD
SpReeD7mo ago
Add this to your AssemblyInfo.cs
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Edit.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.SfSkinManager.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialDark.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialLight.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Shared.Wpf")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Licensing")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.GridCommon.Wpf")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Edit.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.SfSkinManager.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialDark.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialLight.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Shared.Wpf")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Licensing")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.GridCommon.Wpf")]
stigzler
stigzlerOP7mo ago
that's weird - is that in the "XAML Binding Failures" window? If so - I only get this:
stigzler
stigzlerOP7mo ago
No description
SpReeD
SpReeD7mo ago
Okay, it opens and it threw an exception about the token cannot be null, but that's it.
stigzler
stigzlerOP7mo ago
Thanks - but I haven't got an assemblyinfo.cs - should it go in VisGistPackage.cs?
SpReeD
SpReeD7mo ago
You do It's autogenerated
stigzler
stigzlerOP7mo ago
No description
stigzler
stigzlerOP7mo ago
No description
stigzler
stigzlerOP7mo ago
what am i missing?
SpReeD
SpReeD7mo ago
Easiest way to bring it up is to search the project for [assembly. CTRL+SHIFT+F, look in Entire Project or Entire solution and search after [assembly.
SpReeD
SpReeD7mo ago
No description
stigzler
stigzlerOP7mo ago
oh bloody hell - sorry - isn't it nomally in the project root?
SpReeD
SpReeD7mo ago
Depends on the project template, in newer ones it is, but this is the older .net framework template
stigzler
stigzlerOP7mo ago
one moment - got same error, but doing bin/obj delete and vs restart
SpReeD
SpReeD7mo ago
It should look like this:
using System.Reflection;
using System.Runtime.InteropServices;
using VisGist;

[assembly: AssemblyTitle(Vsix.Name)]
[assembly: AssemblyDescription(Vsix.Description)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(Vsix.Author)]
[assembly: AssemblyProduct(Vsix.Name)]
[assembly: AssemblyCopyright(Vsix.Author)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: AssemblyVersion(Vsix.Version)]
[assembly: AssemblyFileVersion(Vsix.Version)]

[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Edit.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.SfSkinManager.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialDark.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialLight.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Shared.Wpf")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Licensing")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.GridCommon.Wpf")]

namespace System.Runtime.CompilerServices
{
public class IsExternalInit { }
}
using System.Reflection;
using System.Runtime.InteropServices;
using VisGist;

[assembly: AssemblyTitle(Vsix.Name)]
[assembly: AssemblyDescription(Vsix.Description)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(Vsix.Author)]
[assembly: AssemblyProduct(Vsix.Name)]
[assembly: AssemblyCopyright(Vsix.Author)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: AssemblyVersion(Vsix.Version)]
[assembly: AssemblyFileVersion(Vsix.Version)]

[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Edit.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.SfSkinManager.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialDark.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Themes.MaterialLight.WPF")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Shared.Wpf")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Licensing")]
[assembly: ProvideCodeBase(AssemblyName = "Syncfusion.GridCommon.Wpf")]

namespace System.Runtime.CompilerServices
{
public class IsExternalInit { }
}
stigzler
stigzlerOP7mo ago
Yep + no dice - same error, interstingly in a different place:
stigzler
stigzlerOP7mo ago
No description
stigzler
stigzlerOP7mo ago
No description
SpReeD
SpReeD7mo ago
Add this assembly to the list
stigzler
stigzlerOP7mo ago
public class LineItem : FrameworkElement
public class LineItem : FrameworkElement
SpReeD
SpReeD7mo ago
Just add [assembly: ProvideCodeBase(AssemblyName = "Syncfusion.Tools.Wpf")]
stigzler
stigzlerOP7mo ago
oh yeah - didn't spot it missing
SpReeD
SpReeD7mo ago
Those are transitive packages of the top-level Syncfusion packages I missed that one
stigzler
stigzlerOP7mo ago
off by 1 error! 🤣# one mo - more probs
SpReeD
SpReeD7mo ago
I guess this it how it should look like
No description
stigzler
stigzlerOP7mo ago
OK - progress, but now I'm getting an error in my code where it executed successfully before on an library referenced in those additions
stigzler
stigzlerOP7mo ago
No description
stigzler
stigzlerOP7mo ago
Does the order in AssemblyInfo.cs matter?
SpReeD
SpReeD7mo ago
Afaik, no But I don't get any errors at all, it's working, thou it does show white text on white background and the gists content doesn't load, but since it's not a finished product I would say it's fine.
SpReeD
SpReeD7mo ago
Creation is somehow working
No description
stigzler
stigzlerOP7mo ago
Yeah - that implies that the SkinManager isn't working. Maybe the theme assemblies weren't being loaded before, but now they are - it's throwing an error. Weird thing is - I used exactly the same libraries and code in another extension and didn't have to do any of this... Shouldn't nuget auto-update projects with the right libs etc?
SpReeD
SpReeD7mo ago
What do you mean by auto-update? Getting the latest version automatically? No. Retrieve dependencies and setting them as transitive packages? Yes.
stigzler
stigzlerOP7mo ago
Yeah - soz - ambiguous. I meant update AssemblyINfo.cs or any other relvant files. Anyways - not to worry - success - I just removed the theme libraries from assemblyinfo.cs and it now owrks *works
SpReeD
SpReeD7mo ago
It does it, but VSIX projects are a bit different to regular projects, it's missing something. Also I'm not very familiar with VSIX dev at all - maybe there are newer project templates for VSIX dev as well
stigzler
stigzlerOP7mo ago
YEah - would make sense. Anyways a huge thank you! I'd never have found that in a million years and any searches cam nowhere near that Right - back to coding I enjoy... (not crap like that!!)
Want results from more Discord servers?
Add your server