Author Topic: Bricscad && .NET  (Read 91296 times)

0 Members and 1 Guest are viewing this topic.

Hans

  • Guest
Re: Bricscad && .NET
« Reply #150 on: October 21, 2010, 04:31:22 AM »
Hi Daniel,

I've been trying to NETLOAD some Dll's from a network drive.
I get following  output at the command prompt:

Die Datei oder Assembly "file:///P:\BRCAD\NET\BrxNet.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Der Vorgang wird nicht unterstützt. (Ausnahme von HRESULT: 0x80131515)

How to load .Net Dlls from network ?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #151 on: October 21, 2010, 07:20:26 AM »
What version of .NET?
What version of Bricscad?
Have you adjusted your security settings to allow .NET modules to run from a network drive?

Hans

  • Guest
Re: Bricscad && .NET
« Reply #152 on: October 21, 2010, 08:21:57 AM »
What version of .NET?
What version of Bricscad?
Have you adjusted your security settings to allow .NET modules to run from a network drive?

BricsCAD Version 10.5.6
I've tried all .Net Platforms (2.0, 3.5, 4.0), netload from local drive works well.
My security settings are adjusted with caspol... (AutoCAD loads the managed dll from the same network drive)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #153 on: October 21, 2010, 09:08:23 AM »
Sorry, I don't have a network drive to test with. I will try to set something up this weekend...  HRESULT: 0x80131515 is a "NotSupportedException". I have no idea why this would happen. are you by any chance using WPF?  have you tried  loading an empty DLL with references RxNet only?

Hans

  • Guest
Re: Bricscad && .NET
« Reply #154 on: October 21, 2010, 10:03:44 AM »
here is the source which i tried to load (no empty project).
I also tried to load the RxNet.DLL from a network drive with following output:

Laden von P:\BRCAD\NET\V10\RxNet.dll
: (arxload "P:/BRCAD/NET/V10/RxNet.dll")
Loading .NET 4.0
:Die Datei oder Assembly "file:///P:\BRCAD\NET\V10\Interop.BricscadApp.10.0.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Der Vorgang wird nicht unterstützt. (Ausnahme von HRESULT: 0x80131515)



   bei CRxNetApp.internalNetload(CRxNetApp* , CStringT<wchar_t\,StrTraitMFC_DLL<wchar_t\,ATL::ChTraitsCRT<wchar_t> > >* path)
:Die Datei oder Assembly "file:///P:\BRCAD\NET\V10\Interop.BricscadDb.10.0.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Der Vorgang wird nicht unterstützt. (Ausnahme von HRESULT: 0x80131515)



   bei CRxNetApp.internalNetload(CRxNetApp* , CStringT<wchar_t\,StrTraitMFC_DLL<wchar_t\,ATL::ChTraitsCRT<wchar_t> > >* path) "P:/BRCAD/NET/V10/RxNet.dll"

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #155 on: October 21, 2010, 10:12:21 AM »
You cannot move the files RxNet.dll, BricscadDb.10.0.dll or BricscadApp.10.0.dll from where the installer installs them.   Did you move them? They must reside in  %systemdrive% %programfiles% \RxNet\V10

Hans

  • Guest
Re: Bricscad && .NET
« Reply #156 on: October 21, 2010, 12:43:45 PM »
Why cannot move to other than installation directory ?
I moved the files RxNet.dll, BricscadDb.10.0.dll and BricscadApp.10.0.dll from %systemdrive% %programfiles% \RxNet\V10 to any other path and all works fine.
Put the files on a network path throws the described error.


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #157 on: October 21, 2010, 09:36:10 PM »
Why cannot move to other than installation directory ?
I moved the files RxNet.dll, BricscadDb.10.0.dll and BricscadApp.10.0.dll from %systemdrive% %programfiles% \RxNet\V10 to any other path and all works fine.
Put the files on a network path throws the described error.



It's by design, the installer adds a registry entry for auto-loading and there is a bit of runtime configuring.
I will take a look at this and find out what this issue  :-)

Helios

  • Guest
Re: Bricscad && .NET
« Reply #158 on: October 21, 2010, 10:09:25 PM »
Daniel,

I had found the RxNet entries in the registry earlier.
When adjusting those, will that allow to move them to an other place?
I'm thinking of relocating those files as well.

Arno

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #159 on: October 21, 2010, 10:25:29 PM »
Nope, But.. I will get in there this weekend and make a few changes so you can put it anywhere you like.

Are you working down there or visiting? Boy, I really miss that place! Did you make the dragon boat races down in Stanley this year?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #160 on: October 26, 2010, 12:11:50 AM »
I have made a few changes, probably breaking.

1, RxNet.DLL is no longer dependant on Bricscad's COM modules at all. This will not affect your code, but it will affect how you reference the COM DLLs in your project. You will need to explicitly reference Bricscad's COM DLLs in your project (using the com tab) and setting the copy local property true, Or, build your own COM metadata DLLs using TLBimp.exe. Visual Studio 2010 no longer needs these metadata DLLs, but you will still need to reference the COM entries if your app uses COM.

2, While the installer still installs the modules in the same location as before, and registers demand loading, you are free to stick the RxNet.DLL wherever you like. You can manually change the demand loading path as well. The RxLoader.txt file should be in the same folder as RxNet.DLL.

I didn't have time to do much testing, so let me know if you run into any issues

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #161 on: October 26, 2010, 08:34:30 PM »
Don't forget about extension methods .

When working with .NET/COM & Bricscad, it can get a little tedious boxing/un-boxing  and casting between .NET and COM types.  Especially if you want to use the custom classes / structs that are in RxNet, such as Matrix3d,Point3d....  You may have rolled your own goodies to use as well.  One way to making things a bit easier is to use Extension Methods   8-)

Code: [Select]
//System
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;

// our using statments
using BricscadApp;
using BricscadDb;
using RxNet.ApplicationServices;
using RxNet.Runtime;
using RxNet.RxGlobal;
using RxNet.Geometry;
using RxNet.DatabaseServices;

namespace RxNetTest
{
  public static class AcadModelSpaceExtentions
  {
    public static AcadLine
      _AddLine(this IAcadModelSpace space, Point3d startPoint, Point3d endPoint)
    {
      return space.AddLine(startPoint.ToArray(), endPoint.ToArray());
    }

    public static AcadCircle
      _AddCircle(this IAcadModelSpace space, Point3d centerPoint, double radius)
    {
      return space.AddCircle(centerPoint.ToArray(), radius);
    }

    public static AcadLWPolyline
      _AddLightWeightPolyline(this IAcadModelSpace space, Point2dCollection points)
    {
      List<double> verts = new List<double>(points.Count);
      foreach (Point2d pt in points)
      {
        verts.Add(pt.X);
        verts.Add(pt.Y);
      }
      return space.AddLightWeightPolyline(verts.ToArray());
    }

    public static AcadLWPolyline
      _AddLightWeightPolyline(this IAcadModelSpace space, Point2dCollection points, bool isClosed)
    {
      AcadLWPolyline pline = space._AddLightWeightPolyline(points);
      pline.Closed = isClosed;
      return pline;
    }

    public static void _Rotate(this AcadLWPolyline entity, Point3d basePoint, double angle)
    {
      entity.Rotate(basePoint.ToArray(), angle);
    }

    public static void _TransformBy(this AcadLWPolyline entity, Matrix3d matrix)
    {
      entity.TransformBy(matrix.To4x4Array());
    }
  }

  public static class Commands
  {
    [CommandMethod("test01")]
    public static void test01()
    {
      AcadApplication application = Application.AcadApplication as AcadApplication;
      AcadDocument document = application.ActiveDocument;
      AcadDatabase database = document.database;
      try
      {
        Point2dCollection pts = new Point2dCollection() {new Point2d(0, 0), new Point2d(0, 100),
                                                         new Point2d(100, 100),new Point2d(100, 0)};

        AcadLWPolyline pline = database.ModelSpace._AddLightWeightPolyline(pts, true);

     
        pline._Rotate(new Point3d(50, 50,0), 45);

        Vector3d vec = (new Point3d(1000, 1000, 0)-new Point3d(91, 323, 0));
        Matrix3d xfrm = Matrix3d.Displacement(vec);

        pline._TransformBy(xfrm);
      }
      catch (System.Exception ex)
      {
        document.Utility.Prompt(String.Format("\n{0}", ex.Message));
      }
    }
  }
}

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #162 on: October 26, 2010, 08:48:35 PM »
Oh I almost forgot, if you're going to use Extension methods, be careful  when overloading existing functions. 
Example, if you have an existing function

Code: [Select]
AddLine(object startPoint,object endPoint);
and you try to overload it with

Code: [Select]
AddLine(this IAcadModelSpace space, Point3d startPoint, Point3d endPoint);

The framework will want to use the first, I guess it's because all objects in .NET derive from System.Object .?.
I just add a underscore at the beginning of the function name to avoid conflicts.

grrrr

  • Guest
Re: Bricscad && .NET
« Reply #163 on: October 27, 2010, 06:45:10 AM »
hi daniel,
i have download rxnet.dll from 26.10.2010 and  and reanimated your early rxnetsample.
but i cant load rxnet.dll cant make a reference to rxnet.dll with this build.
interop.bricscadapp...dll and interop.bricscaddb...dll are ok.
i have tested for v10 and v11

regards
reinhard

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8712
  • AKA Daniel
Re: Bricscad && .NET
« Reply #164 on: October 27, 2010, 09:22:52 AM »
Hi Reinhard, did you happen to get the .NET 4 version or .NET 2. ?