2

I have created a dll following AaronReynoldsUK / PJSIP-PJSUA2-CSharp & used it in my WPF application. which was built and worked as expected. after, I published it(tried Msix packaging/ClickOnce/folder) It ran fine on my pc but after I send it to other Windows pcs, It failed to start on some windows regardless of their versions. checked all the framework dependencies & installed it on those pcs, The issue remained unchanged. when I checked their windows event viewer, I found the following error(summarized),

enter image description here

System.DllNotFoundException: Unable to load DLL 'pjsua2' or one of its dependencies: The specified module could not be found. (0x8007007E)

This error is only visible on the PCs where The App failed to build.

FYI: I am calling all the methods code-behind. Project is built targetting x86 and compiled & published using x86. Also, In the project reference, assembly Copy Local was True.

Please, feel free to ask if you need any more info or to give any suggestions.

Full Error Details:

Provider: .Net Runtime

    CoreCLR Version: 6.0.1322.58009
   .NET Version: 6.0.13
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.Windows.Markup.XamlParseException: 'The invocation of the constructor on type 'MYAPP.Views.Container' that matches the specified binding constraints threw an exception.' Line number '10' and line position '5'.
    ---> System.TypeInitializationException: The type initializer for 'MYAPP.Services.SIPServices.Sip.SipManager' threw an exception.
    ---> System.TypeInitializationException: The type initializer for 'pjsua2PINVOKE' threw an exception.
    ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
    ---> System.DllNotFoundException: Unable to load DLL 'pjsua2' or one of its dependencies: The specified module could not be found. (0x8007007E)
    at pjsua2PINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_pjsua2(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
    at pjsua2PINVOKE.SWIGExceptionHelper..cctor() in E:\rnd23Jan\MYAPP\MYAPP\Services\SIPServices\Classes\pjsua2PINVOKE.cs:line 104
   --- End of inner exception stack trace ---
    at pjsua2PINVOKE.SWIGExceptionHelper..ctor()
    at pjsua2PINVOKE..cctor() in E:\rnd23Jan\MYAPP\MYAPP\Services\SIPServices\Classes\pjsua2PINVOKE.cs:line 124
   --- End of inner exception stack trace ---
    at pjsua2PINVOKE.new_Endpoint()
    at Endpoint..ctor() in E:\rnd23Jan\MYAPP\MYAPP\Services\SIPServices\Classes\Endpoint.cs:line 52
    at MYAPP.Services.SIPServices.Sip.SipManager..cctor() in E:\rnd23Jan\MYAPP\MYAPP\Services\SIPServices\Sip\SipManager.cs:line 26
   --- End of inner exception stack trace ---
    at MYAPP.Services.SIPServices.Sip.SipManager..ctor(EpConfig config, pjsip_transport_type_e tType) in E:\rnd23Jan\MYAPP\MYAPP\Services\SIPServices\Sip\SipManager.cs:line 72
    at MYAPP.Services.PjServices.Sip.SipSingletone..ctor() in E:\rnd23Jan\MYAPP\MYAPP\Services\PjServices\Sip\SipSingletone.cs:line 14
    at MYAPP.Services.PjServices.Sip.SipSingletone.get_GetSipInstance() in E:\rnd23Jan\MYAPP\MYAPP\Services\PjServices\Sip\SipSingletone.cs:line 23
    at MYAPP.Views.Container..ctor() in E:\rnd23Jan\MYAPP\MYAPP\Views\Container.xaml.cs:line 56
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
   --- End of inner exception stack trace ---
    at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
    at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
    at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
    at System.Windows.Application.DoStartup()
    at System.Windows.Application.<.ctor>b__1_0(Object unused)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    at System.Windows.Threading.DispatcherOperation.InvokeImpl()
    at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
    at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Windows.Threading.DispatcherOperation.Invoke()
    at System.Windows.Threading.Dispatcher.ProcessQueue()
    at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
    at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    at System.Windows.Threading.Dispatcher.Run()
    at System.Windows.Application.RunDispatcher(Object ignore)
    at System.Windows.Application.RunInternal(Window window)
    at System.Windows.Application.Run()
    at MYAPP.App.Main()    

Provider: Application Error

    Faulting application name: MyApp.exe, version: 1.0.0.0, time stamp: 0x6387d16c
    Faulting module name: KERNELBASE.dll, version: 10.0.19041.572, time stamp: 0x979ddb1d
    Exception code: 0xe0434352
    Fault offset: 0x00129ab2
    Faulting process id: 0xb8c
    Faulting application start time: 0x01d92f1948c04dcc
    Faulting application path: C:\Users\TestVm\Desktop\net6.0-windows10.0.22621.0\MyApp.exe
    Faulting module path: C:\Windows\System32\KERNELBASE.dll
    Report Id: 88fd7660-b834-434b-8b37-58626cb7408b
    Faulting package full name: 
    Faulting package-relative application ID:    
 
illiterate
  • 98
  • 11
  • 1
    Since it is working on some machines I would check requirements at following webpage : https://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html – jdweng Jan 26 '23 at 07:05
  • Can you please indicate exactly which point you are referring to? I've gone through the doc several times and did everything accordingly. – illiterate Jan 28 '23 at 09:22
  • 1
    I suggest digging into the fusion logs. https://www.google.com/url?sa=t&source=web&rct=j&url=https://stackoverflow.com/questions/32173455/dll-dependency-could-not-be-loaded-how-to-read-fuslogvw&ved=2ahUKEwiK4PjM-en8AhWQCN4KHfL7AqoQFnoECAoQAQ&usg=AOvVaw0VzHAaHV4pY9mQQzwikH8F It is possible that the DLL was found but could not be loaded for various reasons, such as x86/64 missing native deps, file permissions etc... – Aron Jan 28 '23 at 09:30
  • I said the Requirements paragraph. – jdweng Jan 28 '23 at 09:44
  • 1
    The [docs](https://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#building-pjsua2) mention "Standard C++ library is required". It mentions mingw, but that is not accurate. Running dumpbin.exe /imports pjsua2.dll reveals the truth, you have a dependency on the Visual C++ runtime, specifically msvcp140.dll, vcruntime140.dll and vcruntime140_1.dll. Download and run the [vcredist installer](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022) or copy these files into the .exe install directory. – Hans Passant Jan 28 '23 at 13:29
  • If @Hans suggestion didn't work, check whether the project is running on *AnyCpu* even though it's been set up for x86. – Talkhak1313 Feb 03 '23 at 04:20

1 Answers1

2

Thank you everyone for contributing to this issue. It was a really big help. However, this helped me export specific DLLs & referencing thus solving the problem.

Also, In the C++ project properties I had to Change "Copy to Output Directory" for all the project dependencies.

illiterate
  • 98
  • 11