TS3AudioBot icon indicating copy to clipboard operation
TS3AudioBot copied to clipboard

Plugin assembly error

Open MoroseCorpse opened this issue 5 years ago • 17 comments

I have a plugin that generates these errors:

2020-05-04 17:13:48.1732|ERROR||Plugin.InitializeAssembly InitializeAssembly failed: Could not load file or assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

System.IO.FileNotFoundException: Could not load file or assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

File name: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at TS3AudioBot.Plugins.Plugin.InitializeAssembly(Assembly assembly)
2020-05-04 17:07:31.9511|ERROR||Core.UnobservedTaskExceptionHandler Unobserved Task error!
System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Thread, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.Threading.Thread, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at SupportBot.SupportBot.OnEachClientUpdated(Object sender, ClientUpdated client)
   at TSLib.Full.TsFullClient.InvokeEvent(LazyNotification lazyNotification)
   at TSLib.Full.TsFullClient.<>c__DisplayClass40_1.<PacketEvent>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

I fixed the second bug temporarily by commenting out all thread things, but actually I need them. Actually they were just Thread.sleep functions, which I might not need or can be done differently, but still it would be good if I could work with threads

Version 0.12.0-alpha.33/develop/a6260c29

Platform Ubuntu 18.04.4

Both errors were not yet present in the current master version

MoroseCorpse avatar May 04 '20 15:05 MoroseCorpse

I have a new error:

2020-05-04 17:55:30.5455|ERROR||Plugin.StartInternal Plugin 'NowPlaying (BotPlugin)' failed to load: Could not load file or assembly 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
   at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
   at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
   at TS3AudioBot.CommandSystem.CommandManager.<>c__DisplayClass23_0.<<GetCommandMethods>g__GetCommandMethodsIterator|0>d.MoveNext()
   at TS3AudioBot.CommandSystem.CommandManager.GetBotCommands(IEnumerable`1 methods)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at TS3AudioBot.Plugins.PluginCommandBag..ctor(Object obj, Type t)
   at TS3AudioBot.Plugins.Plugin.CreatePluginObjects(IInjector injector, Type type, Boolean isStatic)
   at TS3AudioBot.Plugins.Plugin.StartInternal(Bot bot)

MoroseCorpse avatar May 04 '20 17:05 MoroseCorpse

Check what you are targeting with your plugin. The develop branch currently target dotnet core 3.1 This means your plugin will need to target either netcoreapp3.1 or any netstandard like netstandard2.1

Splamy avatar May 04 '20 17:05 Splamy

The plugins run under the latest netcoreapp3.1

MoroseCorpse avatar May 04 '20 18:05 MoroseCorpse

Are you referencing the exact same TS3AudioBot.dll in your project?

    <Reference Include="TS3AudioBot">
      <HintPath>...\bin\Debug\netcoreapp3.1\TS3AudioBot.dll</HintPath>
    </Reference>

What other references do you have?

Splamy avatar May 04 '20 18:05 Splamy

Yes I refer to the current develop version.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <PackageReference Include="NLog" Version="4.7.0" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="TS3AudioBot">
      <HintPath>..\..\..\TS3AudioBot - 0.12\TS3AudioBot.dll</HintPath>
    </Reference>
    <Reference Include="TSLib">
      <HintPath>..\..\..\TS3AudioBot - 0.12\TSLib.dll</HintPath>
    </Reference>
  </ItemGroup>

</Project>

MoroseCorpse avatar May 04 '20 18:05 MoroseCorpse

I'm sorry, but I can't reproduce this locally. If you want you can try to send me a zip of your projects.

Splamy avatar May 06 '20 12:05 Splamy

Yeah, I can do that. What's the best way for me to send you the projects? Could I send them by email?

MoroseCorpse avatar May 06 '20 15:05 MoroseCorpse

drag and drop into github, otherwise mail if you want

Splamy avatar May 06 '20 15:05 Splamy

Ok so I was just about to send you the email, but then we noticed that if you want to test the plugins, there are a few things to prepare. We could try to explain it in the e-mail, but I think it would be an advantage if you would be okay with meeting on TeamSpeak and going through it together

MoroseCorpse avatar May 06 '20 17:05 MoroseCorpse

Sorry, not responding sooner, I lost tracking here, If you have time you can get on my ts somewhen the next days and I can take some time to look into. Also you can also just send the zip inbefore and I can see I can get it running wihtout explanation

Splamy avatar May 16 '20 14:05 Splamy

So I have now tried again a little bit with the new version. I have now used the brand new version of the develop version. At first I thought that it works, because there was no error, but then I noticed that the bot didn't react to anything, as soon as something like clientlist or something similar was called. I was able to fix this with async as explained in this issue: https://github.com/Splamy/TS3AudioBot/issues/797

But now I have the following problem again:

2020-05-27 21:48:10.4747|ERROR|0|Plugin.StartInternal Plugin 'SupportBot (BotPlugin)' failed to load: Could not load file or assembly 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Das System kann die angegebene Datei nicht finden..
System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Das System kann die angegebene Datei nicht finden.
File name: 'System.Diagnostics.Debug, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
   at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
   at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
   at TS3AudioBot.CommandSystem.CommandManager.<>c__DisplayClass23_0.<<GetCommandMethods>g__GetCommandMethodsIterator|0>d.MoveNext()
   at TS3AudioBot.CommandSystem.CommandManager.GetBotCommands(IEnumerable`1 methods)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at TS3AudioBot.Plugins.PluginCommandBag..ctor(Object obj, Type t)
   at TS3AudioBot.Plugins.Plugin.CreatePluginObjects(IInjector injector, Type type, Boolean isStatic)
   at TS3AudioBot.Plugins.Plugin.StartInternal(Bot bot)

Unfortunately, I have not yet found the time to come to your TS. Besides, I don't know when you're gonna be there anyway. But I spontaneously came up with something how you can test the plugin. So at least the one plugin. If there are still bugs in other plugins, then you would probably have to prepare more.

In any case, in order to use it, you would have to create 4 channels, of which I need the channel IDs in advance, which the bot is allowed to edit. That would mean that the bot would need permissions as well. If you're not sure, we can also provide you with a test TeamSpeak.

I will send you the plugin as soon as possible via email as soon as you have replied.

MoroseCorpse avatar May 27 '20 20:05 MoroseCorpse

Sure, send me and I'll take a look when I get to

Splamy avatar May 29 '20 11:05 Splamy

Ok I have now sent you the project files and explained what you have to do to test the plugin properly

MoroseCorpse avatar May 29 '20 13:05 MoroseCorpse

I haven't got anything yet, did you send it to the correct address?

Splamy avatar May 29 '20 14:05 Splamy

Gmail apparently blocked the email because there were forbidden files in the attachment. I have now simply added a Google Drive Download link to the email

MoroseCorpse avatar May 29 '20 18:05 MoroseCorpse

I was able to fix the bug myself by recompiling the TS3AudioBot again. I think the problem was because we both have different .NET Core versions on our PC. So I have the latest 3.1 .NET Core version (3.1.300). Maybe check if there is a new version available at your site

MoroseCorpse avatar Jun 01 '20 17:06 MoroseCorpse

But now I don't have the file with the dotnet in it anymore, so it would be good if this would work normally again

MoroseCorpse avatar Jun 01 '20 18:06 MoroseCorpse