hi i am trying to make an application which can submit a comment to a youtube video. I am using .net framework 4.0.
when i click a button it spits out this error
Could not load file or assembly 'Google.GData.Client, Version=1.7.0.1, Culture=neutral, PublicKeyToken=04a59ca9b0273830' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
the code i am using is as follows
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;
using System.Web;
using System.Net;
using HtmlAgilityPack;
using System.Xml;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.YouTube;
using Google.GData.Extensions.MediaRss;
using Google.YouTube;
the rest of the code is
string developerKey;
string username;
string password;
developerKey = "mykey";
username = "my username";
password = "my pass";
YouTubeRequestSettings settings = new YouTubeRequestSettings("youtube app", developerKey, username, password);
YouTubeRequest request = new YouTubeRequest(settings);
Uri videoEntryUrl = new Uri("my vid");
Video video = request.Retrieve<Video>(videoEntryUrl);
Comment c = new Comment();
c.Content = "This is my comment from my app";
request.AddComment(video, c);
You're missing an assembly. You must have had it handy as a reference when compiling your app, but it's not there where you're testing.
So it has nothing to do with your code, but your build and deploy process — i.e., shell scripts, NAnt, VS.
A typical YouTube client will have the following DLL's in the same directory as the EXE (or DLL).
Google.GData.Client.dll
Google.GData.Extensions.dll
Google.GData.YouTube.dll
If not, then they need to be installed in the GAC, or otherwise locatable using .NET's assembly binding configuration. Probably you want the first option, though.
Related
I'm going through the sample projects of EPPlus and finally reached the part that I'm interested in. I would like to import contents of a .txt file. Sample 9 shows how to do this, but I get an error I can't seem to fix.
The error message:
The type or namespace name "GetFileInfo" doesn't exist in the namespace 'OfficeOpenXml.Utils'(are you missing an assembly reference?)
The code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OfficeOpenXml;
using System.IO;
using OfficeOpenXml.Table;
using OfficeOpenXml.Drawing.Chart;
using System.Globalization
...
FileInfo newFile = Utils.GetFileInfo(#"\sample9.xlsx");
Does anyone encountered this issue? Thanks in advance!
Edit: If I open directly the sample file I don't get any errors, only if I try to do it in my own project.
Try this:
var file = new System.IO.FileInfo(fullpathandfilename);
I'm trying to establish connection to google cloud for media upload
I've used various methods like Setting environment variable, saving json to mongodb , tried directly load json from file and then loading to google functions
libraries:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using DAL;
using MongoDB;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Configuration;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Auth.OAuth2.Flows;
using System.Drawing;
using Newtonsoft.Json;
using MongoDB;
using MongoDB.Driver.Builders;
using MongoDB.Bson;
Method 1: Using Environment Variable.
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS","onfer-gc.json");
var Credential1 = GoogleCredential.GetApplicationDefaultAsync();
Error : Using Environment Variable.
Error reading credential file from location onfer-gc.json: Error deserializing JSON credential data.
Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS
Method 2: Load json from file
FileStream stream1 = File.OpenRead("onfer-gc.json");
var Credential = GoogleCredential.FromStream(stream1);
Error deserializing JSON credential data.
Method 3: Loading data from Mongodb database and then trying to turn into string
var Db = new Database();
var result = Db.GetCollection<company>().FindOne(Query.EQ("type", "service_account"));
var Credential = GoogleCredential.FromJson(result);
In this case it gives error
Element 'type' does not match any field or property of class MongoDB.company.
Even I've checked solutions online
https://github.com/google/google-api-dotnet-client/issues/747
But it didn't work. What am i doing wrong here ?
My case may not answer the question directly, but it might be possible cause for such error. In my projects I have references to two different versions of Newtonsoft.json, one is 12.0.2 and the other one is 7.0.1. Once I had 7.0.1 updated to same 12.0.2, the json deserializing error solved. This might explain some random working/not-working situations.
I was successfull establishing connection using Method 2:
string credPath = "D:\\Admin\\gcloudcred.json";
var credential = GoogleCredential.FromStream(File.OpenRead(credPath));
var storageClient = StorageClient.Create(credential);
listvideos = storageClient.ListObjects("bucketname");
if (listvideos == null)
{
return listvideos = listvideos1;
}
return listvideos;
I am learning ASP.NET by following one online tutorial (building web application). Problem is when I reuse tutor code I stuck on this error:
Error 1 The type or namespace name 'Uri' could not be found (are you missing a using directive or an assembly reference?)
I tried to include several namespaces (like System.Uri) and none of them worked. Does someone knows where's the problem and what do I need to do to solve the problem?
Here is code:
using System.Collections.Generic;
using System.Net;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Web;
using System.Web.Http;
using System.Net.Http;
using System.Data.Entity.Infrastructure;
using System.Uri;
public HttpResponseMessage Post(Friend friend)
{
if (ModelState.IsValid)
{
db.Friends.Add(friend);
db.SaveChanges();
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, friend);
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = friend.FriendId }));
return response;
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}
You can't have using System.Uri;, since Uri is a class (and static import isn't allowed until Visual Studio 2015, which I suppose you are not using now, even in VS 2015, it would fail since Uri is not a static class)
Include:
using System;
and remove
using System.Uri;
from microsoft doc
http://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx
the refence to include is System.dll This should be there by default. Check if you did not delete it by mistake.
I am using the Microsoft CRM2011 Sample Code, when I try to compile it with Visual Studio 2010, (i use the C-Sharp code only, No VB for me please), i get this error:
Error 13 The type or namespace name 'SystemUser' could not be found
(are you missing a using directive or an assembly reference?) systemuserprovider.cs
I am compiling a file straight from the SDK
...
SystemUser currentUser = serviceProxy.Retrieve(SystemUser.EntityLogicalName, currentUserId, new ColumnSet("domainname")).ToEntity<SystemUser>();
...
Similar issue with
...
// Query to retrieve other users.
QueryExpression querySystemUser = new QueryExpression
{
EntityName = SystemUser.EntityLogicalName,
ColumnSet = new ColumnSet(new String[] { "systemuserid", "fullname" }),
Criteria = new FilterExpression()
};
...
My includes are:
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.DirectoryServices; /* you need System.DirectoryServices.dll */
using System.Linq;
using System.Xml.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Messages;
...
Does anyone know where I can find a definition of SystemUser ?
Mike
The early bound classes must be generated from CRM and included in the project.
There is a utility in the SDK to do this: sdk\bin\CrmSvcUtil.exe
Open a command prompt and move to the bin folder.
Run the program with these parameters:
CrmSvcUtil.exe /username:kingjulian /password:julianisking /url:https://julian.madagascar.com/XRMServices/2011/Organization.svc /out:jCRM.cs /serviceContextName:Context
Username and password are self explanatory
url is the organization service url
out is the cs file to be generated
serviceContextName is the name of the class that you can instantiate and write Linq queries against.
Once jCRM.cs has been added to the project you will have access to the SystemUser class. The file jCRM.cs is located in sdk\bin.
What is the assembly reference for a Filedownloader in c#?
I am looking for to download the files from ftp to my local drive 'c' ,
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
FileDownloader f = new FileDownloader();
which reference should I need to add for the filedownloader?
I guess that you are trying to download files from FTP,and you don't have to use the FileDownloader class.
You can use this link for example: "http://msdn.microsoft.com/en-us/library/ms229711(v=vs.110).aspx".
You can also use an open source to do that, try looking at this link: "http://www.codeproject.com/Tips/443588/Simple-Csharp-FTP-Class"
There is an example of how simple it is to use (From the link above):
ftp ftpClient = new ftp(#"ftp://10.10.10.10/", "user", "password");
ftpClient.download("etc/test.txt", #"C:\Users\metastruct\Desktop\test.txt");