How to read a onedrive folder using c# windows app - c#

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

Related

'InitializeComponent' does not exist in the current context

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

Implement a simple IFindSaga

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

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.

namespace name soapcontext could not be found

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.

SpellCheck in c#

I am writing a c# code for spellchecking using Word.dll. I have used the following site as reference:
http://www.codeproject.com/Articles/2469/SpellCheck-net-spell-checking-parsing-using-C
But i am getting an error: "The type or namespace name 'Word' could not be found (are you missing a using directive or an assembly reference?)"
The code that I am using is:
SpellCheck word = new SpellCheck();
bool status = false;
string s = "youes";
Console.WriteLine("Checking for word : " + s );
// check to see if the word is not correct
// return the bool (true|false)
status = word.CheckSpelling(s);
if (status == false)
{
Console.WriteLine("This word is misspelled : " + s);
Console.WriteLine("Here are some suggestions");
Console.WriteLine("-------------------------");
foreach( string suggestion in word.GetSpellingSuggestions(s) )
{
System.Console.WriteLine( suggestion );
}
}
else if (status == true)
{
Console.WriteLine("This word is correct : " + s );
}
I just want to know how can I make it work?
Create a new class in your solution and call it Word.cs.
Open the “Browse Code” tab in the article at CodeProject, click Word.cs to view it's source code. Copy and paste it to your Word.cs file.
You should download the source code. There is a file named Word.cs, and you should add that file to your project. Word namespace and SpellCheck class are defined in that file.
I think you should add refernce to Micorsoft.Office.Interop.Word under .Net

Categories

Resources