I have a simple IFindSaga implemented, I referred and followed the same steps that was provided in particular software document for SQL Persistence Saga Finding Logic. I'm getting an error at session.GetSagaData<SagaData> stating that: "SynchronizedStorageSession does not contain a definition for GetSagaData and no extension method GetSagaData accepting a first argument of type SynchronizedStorageSession could be found (are you missing a using directive or an assembly reference)." Please help me to solve this.
This is my code where I have implemented IFindSaga
public class TrackerFind : IFindSagas<SagaData>.Using<ITrackerData>
{
public Task<SagaData> FindBy(ITrackerData message, SynchronizedStorageSession session, ReadOnlyContextBag context)
{
return session.GetSagaData<SagaData>(
context: context,
whereClause: "JSON_VALUE(Data,'$.PaymentTransactionId') = #propertyValue",
appendParameters: (builder, append) =>
{
var parameter = builder();
parameter.ParameterName = "propertyValue";
parameter.Value = message.TrackerID;
append(parameter);
});
}
}
"GetSagaData" is an extension method which is part of "NserviceBus" namespace.
include following statement
using NServiceBus;
This worked for me. I am not getting that error now
use nuget
package NServiceBus.Persistence.Sql
Related
I am trying to get Tags to work in a C# AWS CDK project but I can't seem to get anything to work except for the Depreciated syntax. For example in the following code:
using Amazon.CDK;
using Amazon.CDK.AWS.S3;
namespace HelloCdk
{
public class HelloCdkStack : Stack
{
internal HelloCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
// The code that defines your stack goes here
var g_bucket = new Bucket(this, "GameContent", new BucketProps
{
Versioned = false,
PublicReadAccess = true,
AutoDeleteObjects = true, //delete and
RemovalPolicy = RemovalPolicy.DESTROY, //destroy bucket when CF Stack deleted.
WebsiteIndexDocument = "index.html",
WebsiteErrorDocument = "index.html"
});
Tag.Add(g_bucket, "key", "value");
}
}
}
The above code will succeed when I issue the cdk synth command. However, I get a warning message that says:
warning CS0618: 'Tag.Add(Construct, string, string, ITagProps?)' is obsolete: 'use "Tags.of(scope).add()"'
But, when I try to use "Tags.of...", the cdk synth command throws the following error:
error CS1061: 'TagManager' does not contain a definition for 'of' and no accessible extension method 'of'...
What do I need to change to get the recommended tagging approach to work?
Your source code with Tags.of should not compile as there is no such a method for .NET defined.
Documentation specifies Tags.Of - https://docs.aws.amazon.com/cdk/latest/guide/tagging.html
Tags.Of(myConstruct).Add("key", "value");
(!) Notice that the stack object has the Tags property, so make sure you do not access the Tags property of the stack, but Tags class.
Make sure you're using the correct Tags class in Amazon.CDK namespace, and not the Stack.Tags property. Here's how you can get to it directly:
Amazon.CDK.Tags.Of(CONSTRUCT).Add(KEY, VALUE);
I am using Roslyn to parse a very basic WPF solution. I setup a diagnostics and found the following errors:
MainWindow.xaml.cs(25,13): error CS0103: The name
'InitializeComponent' does not exist in the current context
error CS5001: Program does not contain a static 'Main' method suitable
for an entry point
Any idea how to solve this?
UPDATE
So I added a main method and now I am getting the following error:
App.xaml.cs(20,17): error CS1061: 'App' does not contain a definition
for 'InitializeComponent' and no extension method
'InitializeComponent' accepting a first argument of type 'App' could
be found (are you missing a using directive or an assembly reference?)
MainWindow.xaml.cs(25,13): error CS0103: The name
'InitializeComponent' does not exist in the current context
Here is the main method
public partial class App : Application
{
[STAThread]
public static void Main()
{
var app = new App();
app.InitializeComponent();
app.Run();
}
}
If you are loading this solution with code similar to the following:
var ws = MSBuildWorkspace.Create();
var solution = await ws.OpenSolutionAsync(path);
Then the problem is that you are not analyzing the code that should be generated from your .xaml files. This can be solved by changing the above code to:
var properties = new Dictionary<string, string> { ["DesignTimeBuild"] = "true" };
var ws = MSBuildWorkspace.Create(properties);
var solution = await ws.OpenSolutionAsync(path);
For more information, see also https://github.com/dotnet/roslyn/issues/2779
I created two console applications, both targeting v4.5.2 of the .NET framework.
class MyDisposable : IDisposable
{
public void Dispose()
{
var callerName = new StackTrace().GetFrame(1)?.GetMethod()?.Name;
Console.WriteLine($"Dispose called by {callerName}.");
}
}
which run perfectly well.
In the other, I have the following, which are in effect the same.
return Disposable.Create(() =>
{
var stackFrame = new StackFrame();
var callingMethodBase = stackFrame.GetFrame(1)?.GetMethod();
...
});
But Visual Studio intellisense reports:
'StackFrame' does not contain a definition for
'GetFrame' and no extension method 'GetFrame'
accepting a first argument of type 'StackFrame'
could be found (are you missing a using
directive or an assembly reference?)
When I Go to Definition on the StackFramesclass, I see the method GetFrames is absent from the class declaration of the StackFrame class. Both the assembly versions for mscorlib are the same, i.e. v4.0.0.0.
Why is that?
In the first example you are using StackTrace, but in the second you are using StackFrame.
StackTrace has the method GetFrame(), but StackFrame doesn't.
I am building a form application that makes a call to a third party web service, but keep getting a "namespace name soapcontext could not be found" error.
I already added a web reference that points to the wsdl for the web service. Here is what I have:
private void btnGetInfo_Click(object sender, EventArgs e)
{
QTWebSvcsService svc = new qtref.QTWebSvcsService();
// The getVehicleInformation method accepts an AssetIdentifier and returns a
// VehicleInfo object. Instantiate them both.
qtref.AssetIdentifier ai = new qtref.AssetIdentifier();
qtref.VehicleInfo vi = new qtref.VehicleInfo();
// Replace these strings with valid company name, user name and password
string sUsername = "[usernasme]";
string sCompanyname = "[company]";
string sIdentity = sUsername + "#" + sCompanyname;
string sPassword = "[password]";
//This is where it fails
SoapContext requestContext = RequestSoapContext.Current;
}
Here is the exact error:
Error 1 The type or namespace name 'SoapContext' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Sophia Carter\Documents\Visual Studio 2010\Projects\DemoGetVehInf\DemoGetVehInf\Form1.cs 45 13 DemoGetVehInf
Based on the error, it looks like you need a using statement to include the namespace that contains SoapContext.
I don't know what namespace this would be but at the top of your code you will place something like:
using SoapContextNamespace;
I personally use Visual Studio with ReSharper. This combination of tools detects this error and offers a way to correct it with selecting something from the context menu when you right click. Depending on your tool set, you may find this or a similar option.
I transferred VB.Net app to C# and when I build it. This error showed up -
'mshtml.IHTMLImgElement' does not contain a definition for
'getattribute' and no extension method 'getattribute' accepting a
first argument of type 'mshtml.IHTMLImgElement' could be found (are
you missing a using directive or an assembly reference?)
So how can I replace this getattribute call?
This is the code
private void captcha()
{
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2) WebBrowser1.Document.DomDocument;
mshtml.IHTMLControlRange imgrange = (mshtml.IHTMLControlRange) (((mshtml.HTMLBody) doc.body).createControlRange());
foreach (mshtml.IHTMLImgElement img in doc.images)
{
if (img.getattribute("src").ToString().Contains("urltoimg"))
{
imgrange.add((mshtml.IHTMLControlElement) img);
imgrange.execCommand("copy", false, null);
PictureBox1.Image = (System.Drawing.Image) (Clipboard.GetDataObject().GetData(DataFormats.Bitmap));
break;
}
}
}
Try "GetAttribute".
VB is case-insensitive, so "getattribute" would work in VB, however C# (and virtually every other language) is case-sensitive.
You need to cast the mshtml.IHTMLImgElement to an mshtml.IHTMLElement, which will then give you the getAttribute() method
You could replace this line as:
if (((mshtml.IHTMLElement)img.getAttribute("src")).ToString().Contains("urltoimg"))
Note the casing as 'getAttribute', not 'getattribute'.