Using PNP Core Lib in CSOM - issue using AuthenticationManager

%3CLINGO-SUB%20id%3D%22lingo-sub-148508%22%20slang%3D%22en-US%22%3EUsing%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-148508%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETrying%20to%20setup%20my%20MS%20Surface%20for%20doing%20dev%20work%20using%20VS%20Code.%20All%20fine%20for%20JS%20work%2C%20but%20I%20currently%20want%20to%20provision%20Modern%20Pages%20with%20Spfx%20webparts%20as%20per%20the%20PnP%20webcast%20(%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fblogs%2Fprogramatically-creating-and-updating-modern-pages-in-sharepoint-online)%26nbsp%3B%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fblogs%2Fprogramatically-creating-and-updating-modern-pages-in-sharepoint-online)%26nbsp%3B%3C%2FA%3E%20--%20PNP%20Guys%20-%20love%20your%20work!!%20Thank%20for%20everything!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20I%20try%20and%20call%20the%20AuthenticationManager%2C%20I%20am%20getting%20an%20issue%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EException%20has%20occurred%3A%20CLR%2FSystem.MissingMethodException%0AAn%20unhandled%20exception%20of%20type%20'System.MissingMethodException'%20occurred%20in%20OfficeDevPnP.Core.dll%3A%20'Method%20not%20found%3A%20'System.Runtime.Remoting.ObjectHandle%20System.Activator.CreateInstance(System.String%2C%20System.String)'.'%0A%20%20%20at%20OfficeDevPnP.Core.Diagnostics.Log.InitializeLogger()%0A%20%20%20at%20OfficeDevPnP.Core.Diagnostics.Log.Info(String%20source%2C%20String%20message%2C%20Object%5B%5D%20args)%0A%20%20%20at%20OfficeDevPnP.Core.AuthenticationManager.GetSharePointOnlineAuthenticatedContextTenant(String%20siteUrl%2C%20String%20tenantUser%2C%20SecureString%20tenantUserPassword)%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20am%20assuming%20I%20dont%20have%20a%20required%20package%2FDLL%20available%20-%20or%20have%20the%20wrong%20version.%20I%20have%20been%20trying%20to%20install%20required%20packages%20by%20NuGet%20(something%20that%20is%20also%20pretty%20new%20to%20me).%20In%20case%20it%20is%20of%20any%20help%2C%20I%20have%20attached%20the%20project.assets.json%20file%20from%20my%20project.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnyone%20know%20what%20I%20need%20to%20do%20to%20resolve%20this%20issue%3F%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMany%20thanks%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENigel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-148508%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-245888%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-245888%22%20slang%3D%22en-US%22%3E%3CP%3EI%20had%20the%20same%20problem.%20I%20used%20Visual%20Studio%20for%20Mac%20and%20created%20a%20AsP.net%20Core%20Web%20Application%20to%20create%20a%20WebAPI.%20I%20was%20following%20an%20example%20that%20was%20posted%20on%20pnp%20code%20base%20on%20Elevated%20privileges%20and%20I%20ended%20up%20having%20the%20same%20problem.%20I%20ended%20up%20creating%20an%20asp.net%20web%20application%20project%20instead%20then%20added%20OfficeDevPnP%20and%20everything%20worked.%20I%20am%20not%20sure%20what%20dependencies%20were%20added%20but%20it%20worked%20out%20for%20me%20after%20that.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-219033%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-219033%22%20slang%3D%22en-US%22%3E%3CP%3EHey%2C%3C%2FP%3E%3CP%3ESorry%20I%20am%20not%20going%20to%20be%20of%20any%20help%20-%20the%20requirement%20we%20had%20for%20doing%20this%20was%20dropped%20very%20shortly%20after%20my%20posting%2C%20so%20I%20never%20pursued%20it%20any%20further.%3C%2FP%3E%3CP%3EIf%20you%20do%20get%20to%20a%20resolution%2C%20I%20think%20it%20would%20be%20a%20great%20thing%20if%20you%20posted%20your%20solution%20on%20this%20thread%20to%20help%20out%20anyone%20in%20the%20future%20who%20encounters%20the%20same%20issues%3C%2FP%3E%3CP%3EGood%20luck!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-218363%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-218363%22%20slang%3D%22en-US%22%3E%3CP%3EHey%2C%20your%20thread%20result%20first%20on%20my%20search%20for%26nbsp%3B%3CSPAN%3E'System.MissingMethodException'%20occurred%20in%20OfficeDevPnP.Core.dll.%26nbsp%3B%20I'm%20trying%20to%20convert%20a%20.net%204.x%20console%20app%20to%20.net%20core%20that%20I%20run%20in%20VS%20Code%2C%20with%20these%20packages%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3EPackageReference%3C%2FSPAN%3E%20%3CSPAN%3EInclude%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22SharePointPnPCoreOnline%22%3C%2FSPAN%3E%20%3CSPAN%3EVersion%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%222.28.1807%22%3C%2FSPAN%3E%20%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3EPackageReference%3C%2FSPAN%3E%20%3CSPAN%3EInclude%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22System.Configuration.ConfigurationManager%22%3C%2FSPAN%3E%20%3CSPAN%3EVersion%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%224.5.0%22%3C%2FSPAN%3E%20%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3EOn%20the%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3EGetSharePointOnlineAuthenticatedContextTenant%20call%2C%20i%20get%20that%20exception%20and%20i'm%20not%20sure%20what's%20going%20on.%26nbsp%3B%20I%20need%20to%20get%20that%20code%20to%20work%20to%20prove%20to%20my%20team%20that%20VS%20Code%20and%20.NET%20Core%20are%20where%20we%20should%20go%2C%20but%20these%20errors%20make%20me%20doubt%20that%20this%20is%20it%20yet.%26nbsp%3B%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EWere%26nbsp%3B%20you%20able%20to%20authenticate%20to%20SharePoint%20Online%20using%20the%20AuthenticationManager%20from%20PNP%3F%26nbsp%3B%20Does%20it%20only%20work%20in%20.NET%204.x%3F%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-150034%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-150034%22%20slang%3D%22en-US%22%3E%3CP%3EAgreed%20it%20would%20be%20something%20to%20do%20with%20the%20set%20of%20dependencies%20I%20had%20(or%20more%20likely%20didnt%20have)%20in%20my%20own%20project.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20was%20happy%20enough%20to%20modify%20the%20clone%20of%20the%20PnP%20project%20in%20order%20to%20do%20the%20testing%20I%20needed%26nbsp%3Bto%20-%20so%20I%20will%20park%20it%20to%20figure%20out%20another%20day%20%3A)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20for%20the%20response!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-149705%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-149705%22%20slang%3D%22en-US%22%3E%3CP%3ECurious%20what%20you%20are%20exactly%20doing%20and%20what%20your%20code%20looks%20like%20seems%20to%20me%20you%20choose%20the%20wrong%20project%20or%20miss%20the%20dependencies.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-149659%22%20slang%3D%22en-US%22%3ERE%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-149659%22%20slang%3D%22en-US%22%3EYeah%20I%20had%20tried%20it%20in%20Visual%20Studio%20-%20same%20result%20I%20cloned%20the%20whole%0APnP%20repo%2C%20and%20opened%20the%20existing%20sample%20project%20in%20there%20and%20that%0Aworked%20fine%20-%20so%20definitely%20something%20to%20do%20with%20my%20project%0Asetup%2Fincludes%20etc.%20Thanks!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-148631%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20PNP%20Core%20Lib%20in%20CSOM%20-%20issue%20using%20AuthenticationManager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-148631%22%20slang%3D%22en-US%22%3E%3CP%3EI%20assume%20you%20need%20visual%20studio%20instead%20of%20vscode.%20but%20could%20be%20wrong%20here%20have%20not%20watched%20the%20whole%20video.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hi,

 

Trying to setup my MS Surface for doing dev work using VS Code. All fine for JS work, but I currently want to provision Modern Pages with Spfx webparts as per the PnP webcast (https://dev.office.com/blogs/programatically-creating-and-updating-modern-pages-in-sharepoint-online... -- PNP Guys - love your work!! Thank for everything!

 

When I try and call the AuthenticationManager, I am getting an issue:

 

Exception has occurred: CLR/System.MissingMethodException
An unhandled exception of type 'System.MissingMethodException' occurred in OfficeDevPnP.Core.dll: 'Method not found: 'System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)'.'
   at OfficeDevPnP.Core.Diagnostics.Log.InitializeLogger()
   at OfficeDevPnP.Core.Diagnostics.Log.Info(String source, String message, Object[] args)
   at OfficeDevPnP.Core.AuthenticationManager.GetSharePointOnlineAuthenticatedContextTenant(String siteUrl, String tenantUser, SecureString tenantUserPassword)

 

I am assuming I dont have a required package/DLL available - or have the wrong version. I have been trying to install required packages by NuGet (something that is also pretty new to me). In case it is of any help, I have attached the project.assets.json file from my project.

 

Anyone know what I need to do to resolve this issue??

 

Many thanks

 

Nigel

7 Replies
Highlighted

I assume you need visual studio instead of vscode. but could be wrong here have not watched the whole video.

Highlighted
Yeah I had tried it in Visual Studio - same result I cloned the whole PnP repo, and opened the existing sample project in there and that worked fine - so definitely something to do with my project setup/includes etc. Thanks!
Highlighted

Curious what you are exactly doing and what your code looks like seems to me you choose the wrong project or miss the dependencies.

Highlighted

Agreed it would be something to do with the set of dependencies I had (or more likely didnt have) in my own project.

 

I was happy enough to modify the clone of the PnP project in order to do the testing I needed to - so I will park it to figure out another day :)

 

Thanks for the response!

 

Highlighted

Hey, your thread result first on my search for 'System.MissingMethodException' occurred in OfficeDevPnP.Core.dll.  I'm trying to convert a .net 4.x console app to .net core that I run in VS Code, with these packages:

 

<PackageReference Include="SharePointPnPCoreOnline" Version="2.28.1807" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
 
On the GetSharePointOnlineAuthenticatedContextTenant call, i get that exception and i'm not sure what's going on.  I need to get that code to work to prove to my team that VS Code and .NET Core are where we should go, but these errors make me doubt that this is it yet.  
 
Were  you able to authenticate to SharePoint Online using the AuthenticationManager from PNP?  Does it only work in .NET 4.x?
Highlighted

Hey,

Sorry I am not going to be of any help - the requirement we had for doing this was dropped very shortly after my posting, so I never pursued it any further.

If you do get to a resolution, I think it would be a great thing if you posted your solution on this thread to help out anyone in the future who encounters the same issues

Good luck!

Highlighted

I had the same problem. I used Visual Studio for Mac and created a AsP.net Core Web Application to create a WebAPI. I was following an example that was posted on pnp code base on Elevated privileges and I ended up having the same problem. I ended up creating an asp.net web application project instead then added OfficeDevPnP and everything worked. I am not sure what dependencies were added but it worked out for me after that. 

 

Hope this helps.