SystemUser class in CRM2011 SDK Sample Code - c#

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.

Related

TcpChannel could not be found

I'm following a lab tutorial on .NET remoting and for that I need to create TcpChannel object. For that I have added using System.Runtime.Remoting namespace but it still gives me an error The type or namespace name 'TcpChannel' could not be found (are you missing a using directive or an assembly reference?)
I'm using Visual Studio 2015 Community Edition. I can't figure out what is causing this problem. I even googled it. Here's my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Remoting;
namespace RemotingServer
{
class Program
{
static void Main(string[] args)
{
TcpChannel channel = new TcpChannel(8001);
}
}
}
The TcpChannel class is located in System.Runtime.Remoting.Channels.Tcp, so you have to get using that. Also check if you reference System.Runtime.Remoting.dll in your project.

Cannot find the namespace for generic type "List"

I have a strange error and don't know how to solve that. I have a Form which gets opened by another (Main)Form. When I write
List<String> valStoreAsString = new List<String>();
I get "The value or namespace List could not get found". My using directives are the following:
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Collections;
using System.Runtime.InteropServices;
In the other Forms it works fine. What happened here?
Add following using directive to the list of usings.
using System.Collections.Generic;
Tip
If you are using Visual Studio and if you don't know the namespace then type name of type (Case sensetive) in editor and then press ctrl+ . and select add using option and VS will add related using for you.
or you can right click on name of Type and select Resolve option and select using .... sub option.

The type or namespace name 'Uri' could not be found: (System.Uri namespace is included)

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.

How to Use Ado.net Model in Helper Class in asp.net c#

I have a folder
Helper
1. Class (SessionManagement.cs)
I have Model.edmx at root.
How can I use Model in my SessionManagement Class
I want it like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NGO_MS.Model; // Error is The type or name space Model does not exist
using NGO_MS.Controls;
using System.Net.Mail;
using System.Net;
using System.Web.UI;
using NSLogger;
using NGO_MS.DAL;
using System.Configuration;
My question is how can i use it with using ? I am beginer Kindly guide me.
Inside a method in your SessionManangement class paste the following code.
using (Model ctx = new Model()){
}

c# youtube api error

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.

Categories

Resources