I am working on migration from .NET SDK 2.7 to .NET SDK 3.0. Couchbase server 6.0.
This code throws NullReferenceException. I can't understand what I am doing wrong. I can't put the exception call stack. The site tells me that I have too much code or exception should be marked as code.
var options = new ClusterOptions()
.WithConnectionString("http://192.168.1.120:8091") //Node's IP
.WithCredentials("User", "Password")
.WithBuckets("SomeBucket");
var cluster = await Cluster.ConnectAsync(options);
It was a problem in SDK and it was fixed in 3.0.2. But right now I am getting the same error on getting buckets. So need to wait for the new SDK version again :-)
Update
Some more details u can get here.
Shortly. Remove the port and all will be more or less OK.
Related
We have created a signature in a .Net Core web api, using X509Certificate2.GetECDsaPrivateKey on a .pfx certificate file, and need to verify this signature in our Xamarin Android app, using the public key (.crt). I can run the code on a normal Windows .Net Framework 4.6.1 app and it works. If I change the Framework version to anything lower, my app doesn't compile, as the GetECDsaPublicKey method was only implemented in 4.6.1. In my Xamarin app, I can compile the app and it runs, but as soon as I reach the line that executes the GetECDsaPublicKey method, I get a NotImplemented exception. There is literally no information on this on the internet, apart from the Microsoft documentation, which doesn't give much in any case. Can anyone shed any light onto why this error occurs? Here are the few lines of code to load the certificate and verify the signature (I've taken out some unnecessary error checking code):
string FileName = "public_key.crt";
string certPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileName);
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certPath);
System.Security.Cryptography.ECDsa eCDsa = certificate.GetECDsaPublicKey(); // This line causes the exception
Even just executing this line, gives the same error:
System.Security.Cryptography.ECDsa eCDsa = System.Security.Cryptography.ECDsa.Create();
So if anyone comes across this also struggling with it, there is a post that answers this question - Are ECDSA and ECDH available for mono?
Sadly, we will have to either use a different encryption/signing algorithm or use something like BouncyCastle...
I need to call a web service on an old legacy system and I pilfered some code to do that from an old Silverlight app (which I didn't write) that is targeting .NET 4. I verified the code works. However when I put that code in my app targeting .NET Core 3.1 I get the following error when calling ReadToEnd() on the StreamReader:
System.IO.IOException: 'The response ended prematurely, with at least 185 additional bytes expected.'
I created two identical console apps, one targeting .NET 4.7, the other targeting .NET Core 3.1, and sure enough, it worked on 4.7 but not on Core 3.1. I know code page 1252 is not supported in .net Core and I played around with other values to see if that was the issue with no luck.
I've found what I would consider a hacky workaround, spinning it byte by byte and using the Peek() method (ReadLine() doesn't work either) so I know I'm actually getting data back but I'm hoping the brilliant minds out there can help me understand 1) why ReadToEnd() is throwing in .NET Core and 2) whether there's a better way to do this, keeping in mind I have no control of the web service on the legacy system.
Thanks in advance for your help!
WebRequest requestGetPODetails = WebRequest.Create(myURL);
requestGetPODetails.Method = "POST";
var postContentsBuffer = Encoding.GetEncoding(1252).GetBytes(someXML);
requestGetPODetails.ContentLength = postContentsBuffer.Length;
using (Stream sfdDataStream = requestGetPODetails.GetRequestStream())
sfdDataStream.Write(postContentsBuffer, 0, postContentsBuffer.Length);
// Retrieve the results
using (WebResponse responseGetPODetails = requestGetPODetails.GetResponse())
{
Encoding enc = Encoding.GetEncoding(1252);
using (StreamReader sfdDataStreamReader = new StreamReader(responseGetPODetails.GetResponseStream(), enc))
{
string stringResponse = sfdDataStreamReader.ReadToEnd(); // Error occurs here in .NET Core
}
}
Huge thanks to Alexei Levenkov! You were exactly right--the service was incorrectly reporting the length of the stream. I reached out to the legacy developer and he was able to fix that and now all is well.
The weird thing is that this was working under .NET Framework but not Core so something apparently changed with Core as it now cares that the length is reported accurately.
Thanks again!
I am using VS2017 in Mac( with latest packages added for Azure Service Bus), to pull a message from Service bus Queue in Azure. On execution of below code, getting the error
BadImageFormatException - could not resolve field token 0x0400089c
Its coming from CreateFromConnectionString and the stack points to MessageFactory.create call which happens under the hood, on our call to CreateFromConnectionString.
Got many pointers like x86 issue and all, but none were certain on what to look into. I was using Release x86, then tried Rel AnyCpu as well.
Does anyone faced this issue before or any pointers to resolve this.
string connectionString = "Endpoint=sb://spxxxx.servicebus.windows.net/;SharedAccessKeyName=Root**Key;SharedAccessKey=xxxx.......xxxxxxxx=";
string queueName = "spqueue";
QueueClient client = QueueClient.CreateFromConnectionString(connectionString, queueName);
Also did an trail by creating the MessageFactory in the program itself. Got same error at MessagingFactory.Create
Also connectionString and queue name are fine, as I am able to generate the Authorization token correctly using this code and postman connected to the Q using the same without any issues.
Thanks!
Let me know if any additional details needs to be added.
AFAIK, Visual Studio 2017 for Mac provides the ability for using Xamarin and .NET Core to build mobile,web, and cloud applications on macOS. Per my understanding,
the Microsoft Azure Service Bus 4.1.3 targets on the traditional .NET Framework, you could try to use the next generation Azure Service Bus .NET Standard client library Microsoft.Azure.ServiceBus 0.0.7-preview.
I have an ASP.NET MVC 3 application which uses PowerShell to connect to Office 365 to retrieve some details about user licenses.
The code itself works in many cases:
The project in my local IIS works
A piece of code in LINQPad using the library works on my machine
A piece of code in LINQPad using the library works on the target server
And where it doesn't work is of course the only place it really should work: The IIS on the target server.
I always get an Exception when calling the Connect-MsolService cmdlet. The problem is that the Exception doesn't tell me anything.
The Exception type is
Microsoft.Online.Administration.Automation.MicrosoftOnlineException
and the message is
Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown
which is pretty useless.
The Office 365 user account I use in my code is always the same. The user account used to start the IIS is always the same, too (Local System).
I wrapped the PowerShell code execution in a class named PowerShellInvoker. Its code can be found here.
And here is the code that connects to Office 365:
var cred = new PSCredential(upn, password);
_psi = new PowerShellInvoker("MSOnline");
_psi.ExecuteCommand("Connect-MsolService", new { Credential = cred });
There is no Exception actually thrown, the error is found in the Error property of the pipeline. (See lines 50ff. of the PowerShellInvoker class.)
The problem is that I don't know what could be wrong, especially because the same code works when I use LINQPad. The search results by Google couldn't help me either.
The server runs on Windows Server 2008 R2 Datacenter SP1 with IIS 7.5.
I found the solution!
I don't know the reason, but on the target server, the app pool's advanced settings for my app had set Load User Profile to False. I changed it back to True (which should be default) and voilĂ , it works!
Edit: The Load User Profile setting was apparently automatically set to False by default because the IIS 6.0 Manager was installed and False was the default behavior until IIS 6.0.
I'm using MVC 4 (beta), and having some problems trying to test an auth attribute I've written.
In order to look into this some more, I'm trying to use the debug into .net framework sources debugging options, to see exactly what is going wrong. I've followed the setup instructions here: http://weblogs.asp.net/gunnarpeipman/archive/2010/07/04/stepping-into-asp-net-mvc-source-code-with-visual-studio-debugger.aspx
After doing all this, when I debug into my tests to see what is going on, when I come to step into the line of code that calls into the .net fw, the test just terminates and gives me the exception I'm trying to debug. For completeness, here's my code:
var controller = new MyController();
controller.SetFakeAuthenticatedControllerContext("foo"); // Set up a fake http context for the user
var actionDescriptor = new Mock<ActionDescriptor>();
actionDescriptor.SetupGet(x => x.ActionName).Returns("AddedForTest");
var context = new AuthorizationContext(controller.ControllerContext, actionDescriptor.Object);
var auth = new SamCommandAuthenticationAttribute();
auth.OnAuthorization(context); // On this line the test will just terminate
Assert.Pass(); // This line would never be called.
Does anyone know why I'm not able to debug into the .net sources?
Microsoft Symbol server provides symbols for a subset of .net framework assembly.
I don't think Mvc4 beta is one of them...
----Added---
As Bond pointed out in the comment if you want to step into MVC4 Beta sources you have to include the mvc project in your solution and reference it from there, by first removing the reference to the GAC version which you've installed