Open kombasltd opened 6 years ago
The only thing I can spot is that you are using client2.NewPost but have never declared client2... although you should be getting obj not set to instance error
On Mon, Aug 13, 2018 at 12:07 PM komBAS notifications@github.com wrote:
Hi,
as I mentioned in another issue, I am evaluating WordPressSharp to use it in a new application of mine (used Joe Blogs in WinForms app for now). Now I am developing an web app with ASP.Net Core 2.1 MVC and I am struggeling.
The following code works fine in a WinForm app but not in my MVC app:
using WordPressSharp.Models; using WordPressSharp;
public bool WPPostTest() { var post = new Post { PostType = "post", // "post" or "page" Title = "Using WordPressSharp", Content = "WordPressSharp is a C# utility for interfacing with the WordPress XML-RPC API", PublishDateTime = DateTime.Now, Status = "publish" // "draft" or "publish" };
var client = new WordPressClient(new WordPressSiteConfig { BaseUrl = "https://wptest.kombas.de", BlogId = 1, Username = "USERNAME", Password = "PASSWORD" });
using (client) { var id = client2.NewPost(post); }
return true; }
Exception is:
An unhandled exception occurred while processing the request. MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'. CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, string assemblyName, string moduleName, string typeName, AssemblyBuilderAccess access)
Stack Query Cookies Headers MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'. CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, string assemblyName, string moduleName, string typeName, AssemblyBuilderAccess access) CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf) WordPressSharp.WordPressClient..ctor(WordPressSiteConfig siteConfig) komBASSEOServices.Controllers.WordPressProjectsController.WPPostTest() in WordPressProjectsController.cs + var client2 = new WordPressClient(new WordPressSiteConfig lambda_method(Closure , object , object[] ) Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters) Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Do you have any idea?
Thanks, Kay
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/abrudtkuhl/WordPressSharp/issues/93, or mute the thread https://github.com/notifications/unsubscribe-auth/AATsrFMvbPwpXHbQsmSuhVftM-hmd-VTks5uQbJEgaJpZM4V64kZ .
Oh my bad, sorry. I edited the source here. Of course it's "client" and not "client2".
I continued to try but there seems to be a general problem within an ASP.NET MVC app, even in the simplest form. The problem seems to be this one here:
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'. CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, string assemblyName, string moduleName, string typeName, AssemblyBuilderAccess access)
But at the moment I have no clue if the exception comes from xmp-rpc.net or WordPressSharp?
I'll give it another try ;-)
Maybe you or someone else can confirm the following test:
public IActionResult About()
{
// create a new Post in WordPress
var post = new Post
{
PostType = "post", // "post" or "page"
Title = "Using WordPressSharp",
Content = "WordPressSharp is a C# utility for interfacing with the WordPress XML-RPC API",
PublishDateTime = DateTime.Now,
Status = "publish" // "draft" or "publish"
};
var client = new WordPressClient(new WordPressSiteConfig
{
BaseUrl = "http://yourwpblog",
BlogId = 1,
Username = "username",
Password = "password"
}
);
using (client)
{
var id = client.NewPost(post);
}
ViewData["Message"] = "Your application description page.";
return View();
}
Which results here in a
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'. CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, string assemblyName, string moduleName, string typeName, AssemblyBuilderAccess access) CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf) WordPressSharp.WordPressClient..ctor(WordPressSiteConfig siteConfig) in WordPressClient.cs + WordPressService = (IWordPressService)XmlRpcProxyGen.Create(typeof(IWordPressService)); WPSharpTest.Controllers.HomeController.About() in HomeController.cs + var client = new WordPressClient(new WordPressSiteConfig lambda_method(Closure , object , object[] ) Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters) Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
It would be very kind when I could get a confirmation because I can stop to fiddle around with this.
Best regards, Kay
I haven’t used .net core with the library so I cannot confirm that it works as expected
From: komBAS notifications@github.com Sent: Saturday, August 18, 2018 9:29 AM To: abrudtkuhl/WordPressSharp Cc: Andy Brudtkuhl; Comment Subject: Re: [abrudtkuhl/WordPressSharp] WordPressSharp with ASP.Net Core 2.1 (#93)
I'll give it another try ;-)
Maybe you or someone else can confirm the following test:
public IActionResult About() { // create a new Post in WordPress var post = new Post { PostType = "post", // "post" or "page" Title = "Using WordPressSharp", Content = "WordPressSharp is a C# utility for interfacing with the WordPress XML-RPC API", PublishDateTime = DateTime.Now, Status = "publish" // "draft" or "publish" };
var client = new WordPressClient(new WordPressSiteConfig
{
BaseUrl = "http://yourwpblog",
BlogId = 1,
Username = "username",
Password = "password"
}
);
using (client)
{
var id = client.NewPost(post);
}
ViewData["Message"] = "Your application description page.";
return View();
}
Which results here in a
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'. CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, string assemblyName, string moduleName, string typeName, AssemblyBuilderAccess access) CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf) WordPressSharp.WordPressClient..ctor(WordPressSiteConfig siteConfig) in WordPressClient.cs + WordPressService = (IWordPressService)XmlRpcProxyGen.Create(typeof(IWordPressService)); WPSharpTest.Controllers.HomeController.About() in HomeController.cs + var client = new WordPressClient(new WordPressSiteConfig lambda_method(Closure , object , object[] ) Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters) Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
It would be very kind when I could get a confirmation because I can stop to fiddle around with this.
Best regards, Kay
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/abrudtkuhl/WordPressSharp/issues/93#issuecomment-414061887, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AATsrJpkJCumqbXr87aNHOA39CswqG55ks5uSCTNgaJpZM4V64kZ.
Hi,
as I mentioned in another issue, I am evaluating WordPressSharp to use it in a new application of mine (used Joe Blogs in WinForms app for now). Now I am developing a web app with ASP.Net Core 2.1 MVC and I am struggeling.
The following code works fine in a WinForm app but not in my MVC app:
Exception is:
Do you have any idea?
Thanks, Kay