Results 1 to 5 of 5

Thread: VS2022 CRM v8.3 on premises Early & late bound classes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2016
    Posts
    25

    VS2022 CRM v8.3 on premises Early & late bound classes

    I'm trying to build a simple web application project which connects to an on premises development CRM version 8.3 for reading records, without having to use an expensive 3 party product. Currently I have been looking at a few tutorials, but they are in in C.

    I'm eventually looking to expand the project, but just need to get the basics covered first

    This is all inhouse and there is no ADFS connection to the development CRM server.

    Can anyone point me in the direction of a walk through or tutorial in vb.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,348

    Re: VS2022 CRM v8.3 on premises Early & late bound classes

    I saw this C to VB converter https://www.codeconvert.ai/c-to-vb.net-converter

    Never used it so I don't know if it works.

    If not then post the C code and maybe someone here can help you convert it.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2016
    Posts
    25

    Re: VS2022 CRM v8.3 on premises Early & late bound classes

    Quote Originally Posted by wes4dbt View Post
    I saw this C to VB converter https://www.codeconvert.ai/c-to-vb.net-converter

    Never used it so I don't know if it works.

    If not then post the C code and maybe someone here can help you convert it.

    Hi ,

    I don't think the conversion is the issue. I think its more to do with the version of .net , but I'm not sure. I was following the walkthrough https://learn.microsoft.com/en-us/pr...ectedfrom=MSDN

    when trying to run it I get

    Server Error in '/' Application.
    Could not load type 'Xrm.XrmServiceContext'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Could not load type 'Xrm.XrmServiceContext'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [HttpException (0x80004005): Could not load type 'Xrm.XrmServiceContext'.]
    System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +382
    System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +102

    [InvalidOperationException: Could not find the type specified in the ContextTypeName property of LinqDataSource 'Contacts'.]
    System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +431
    System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTable(DataSourceOperation operation) +1087
    System.Web.UI.WebControls.LinqDataSourceView.CreateContextAndTableForSelect() +186
    System.Web.UI.WebControls.ContextDataSourceView.GetSource(QueryContext context) +30
    System.Web.UI.WebControls.LinqDataSourceView.GetSource(QueryContext context) +359
    System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +81
    System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +22
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +134
    System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +107
    System.Web.UI.Control.EnsureChildControls() +130
    System.Web.UI.Control.PreRenderRecursiveInternal() +66
    System.Web.UI.Control.PreRenderRecursiveInternal() +297
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7474

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2016
    Posts
    25

    Re: VS2022 CRM v8.3 on premises Early & late bound classes

    This isn't pretty, but I am only testing. I've has a little success and managed to retrieve records from D365 (on premises), with X returning the correct number of records
    Function Index() As ActionResult

    Dim crmUrl = New Uri("http://VS-CRM:5555/VSCRM")
    Dim clientCredentials As ClientCredentials = New ClientCredentials()
    clientCredentials.UserName.UserName = "MyName"
    clientCredentials.UserName.Password = "MyPassword"
    Dim service = New OrganizationServiceProxy(New Uri("http://MyCRM/XRMServices/2011/Organization.svc"), Nothing, clientCredentials, Nothing)

    Dim userid As Guid = (CType(service.Execute(New WhoAmIRequest()), WhoAmIResponse)).UserId

    If userid <> Guid.Empty Then
    MsgBox("Connection Established Successfully...")
    Else
    MsgBox("Failed to Established Connection!!!")
    End If

    Dim query = New QueryExpression("contact")
    query.ColumnSet = New ColumnSet("fullname")
    Dim contact = service.RetrieveMultiple(query)

    Dim nameslist = From na In contact.Entities
    Dim X = nameslist.Count
    Return View(nameslist.ToList)
    End Function

    Model
    Public Class contact
    Public Property fullname As String
    End Class

    The issue I am facing is trying to get that data into a MCV List view

  5. #5
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,827

    Re: VS2022 CRM v8.3 on premises Early & late bound classes

    Not a Dynamics person so take this advice with a healthy bit of scepticism...

    Rather than going through COM there is a REST API https://learn.microsoft.com/en-us/dy...es?view=op-9-1 that might work better.

    Also https://www.nuget.org/packages?q=dyn...rtby=relevance shows a lot of potentially useful nuget packages, they might make it easier to work with .Net and Dynamics.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width