namespace name soapcontext could not be found - c#

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.

Related

AWS cdk how to tag resources in c#?

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);

fakeXrmEasy for crm testing initialization issues

I'm trying to follow the basic tutorial for FakeXrmEasy, but I'm not sure why I'm getting errors. I installed everything that needs to be installed to mock Dynamics 365, but I'm still getting errors. I can't figure out what I'm missing, I really want to be able to use this tool.
CS1950 The best overloaded Add method 'List.Add(Entity)' for the collection initializer has some invalid arguments unitTest c:\Users\acapell\documents\visual studio 2015\Projects\unitTest\unitTest\Program.cs 48 Active
CS0246 The type or namespace name 'Account' could not be found (are you missing a using directive or an assembly reference?) unitTest c:\Users\acapell\documents\visual studio 2015\Projects\unitTest\unitTest\Program.cs 45 Active
Didn't know if I was suppose to create an account class, I also tried that but that didn't work either. I got
CS1503 Argument 1: cannot convert from 'unitTest.Account' to 'Microsoft.Xrm.Sdk.Entity' unitTest c:\Users\acapell\documents\visual studio 2015\Projects\unitTest\unitTest\Program.cs 48 Active
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using FakeItEasy;
using FakeXrmEasy;
using Microsoft.Xrm.Sdk;
namespace unitTest
{
class Program
{
static void Main(string[] args)
{
}
}
class unitTest
{
public object ProxyTypesAssembly { get; private set; }
public void MyFirstTest()
{//test method body
var context = new XrmFakedContext();
//You can think of a context like an Organisation database which stores entities In Memory.
//We can also use TypedEntities but we need to tell the context where to look for them,
//this could be done, easily, like this:
context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));
//We have to define our initial state now,
//by calling the Initialize method, which expects a list of entities.
var account = new Account() { Id = Guid.NewGuid(), Name = "My First Faked Account yeah!" };
context.Initialize(new List<Entity>() {
account
});
}
}
}
Do you use early binding in your CRM project and got the references right? If you do not use early binding, you can try late binding, e.g.
//context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));
var account = new Entity();
account.LogicalName = "account";
account.Attributes["name"] = "your account name";

How to add a class in WCF service and use in ASP.NET web application?

I want to add this class in WCF Service and use in AP.NET web Application.
public class Message
{
public String sender_Id;
public String message;
}
I want to call a function from ASP.NET web application which lies in WCF that will return an ArrayList containing objects of above mentioned Message Class.
I have added reference also but it says -
Error 1 'object' does not contain a definition for 'sender_Id' and no extension method 'sender_Id' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) C:\Users\abhinav\documents\visual studio 2010\Projects\wcf_web_app\wcf_web_app\Default.aspx.cs 42 59 wcf_web_app
sender_Id is a data member in class Message.
protected void Button2_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
ArrayList messages = new ArrayList(client.receiveMsg(ReceiverId_R.Text));
receiveMsg_div.InnerHtml = "";
foreach(var messg in messages)
{
receiveMsg_div.InnerHtml += "<p>" + messg.sender_Id + "send message" + messg.message + "</p>";
}
}
messg.sender_Id and mssg.message is the problem. It does not recognize what sender_Id and message are ? What could be the problem ?
I have also used SvcUtil.exe and created the file output.config and Service1.cs and have put it inside ASP.NET Web Application that is using the WCF Service.

How to fix ambiguous reference errors?

I have a web app that allows importing of contacts from Hotmail, Yahoo and GMail. I finally have it almost completed but since I added the importing of GMail, I am getting ambiguous reference errors and I am unsure how to fix them without breaking any code.
Here is a screen shot of the errors:
Try to use unique class names as much as possible. This will be the better solution in the end.
Write the entire namespace when referencing
OAuth.OAuthBase a = new ...;
Google.GData.Client.OAuthBase b = new ...;
Make an using alias for one or both:
using n2 = OAuth;
using Google.GData.Client;
n2.OAuthBase a = new ...; // referenced using namespace
OAuthBase b = new ...; // referenced through existing `using`
you can try something like this..
using GoogleOAuthBase = Google.GData.Client.OAuthBase;
namespace abc
{
public class Program
{
//make sure this Google.GData.Client.OAuthBase is instansiateable
var googleBase = new GoogleOAuthBase();
}
}
you can try entire name space as well.
var googleBase = new Google.GData.Client.OAuthBase();

How to read a onedrive folder using c# windows app

I am trying to follow a sample on MSDN to read the properties of a folder on onedrive, but I am running into some errors.
Here is the tutorial I am following: http://msdn.microsoft.com/en-us/library/live/hh826522.aspx#reading_albums
The error I get when I run the code says:
"Error 1 'testRun.MainPage' does not contain a definition for 'session' and no extension method 'session' accepting a first argument of type 'testRun.MainPage' could be found (are you missing a using directive or an assembly reference?) C:\Users\me\Desktop\project"
I have still looked into the issue, and haven't found out what I need to include for the LiveConnectClient parameter. It only gives that it needs "LiveConnectClient session", and I am not sure what to place in for that.
My Code:
private async void Button_logIn_Click(object sender, RoutedEventArgs e)
{
try
{
LiveConnectClient liveClient = new LiveConnectClient(this.session);
LiveOperationResult operationResult =
await liveClient.GetAsync("path/to/folder");
dynamic result = operationResult.Result;
this.Textblock_status.Text = string.Join(" ", "Album name:", result.name, "ID:", result.id);
}
catch (LiveConnectException exception)
{
this.Textblock_status.Text = "Error getting album info: " + exception.Message;
}
}
You need to make sure you're defining the session member, and populating it with a valid session prior to using it with LiveConnectClient. Check out the following documentation for a more complete example:
http://msdn.microsoft.com/en-US/library/dn631823.aspx

Categories

Resources