Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit API error on trying to invoke Microsoft.ML from an external command class, cant load system.memory error.

3 REPLIES 3
Reply
Message 1 of 4
frankholidayjunior
855 Views, 3 Replies

Revit API error on trying to invoke Microsoft.ML from an external command class, cant load system.memory error.

 
 

So far what has worked is converting .netcore to .net frameworks 4.7.2 , calling from an external windows application using a windows form. As soon as i convert to a class use the external command I start getting these bizzarre errors. I have all the system.meory references in both projects an nuget seems to be effective at providing all the dependencies, however I keep getting the below "Cant load system.memory" error in one form or another exception.

************** Exception Text **************
System.FormatException: Parsing failed with an exception: The type initializer for 'System.MemoryExtensions' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.MemoryExtensions' threw an exception. ---> System.MissingMethodException: Method not found: 'IntPtr System.Runtime.CompilerServices.Unsafe.ByteOffset(!!0 ByRef, !!0 ByRef)'.
   at System.MemoryExtensions.MeasureStringAdjustment()
   at System.MemoryExtensions..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.ML.Data.TextLoader.Parser.ParseRow(RowSet rows, Int32 irow, Helper helper, Boolean[] active, String path, Int64 line, String text)
   at Microsoft.ML.Data.TextLoader.Cursor.ParallelState.Parse(Int32 tid)
   at Microsoft.ML.Data.TextLoader.Cursor.ParallelState.ThreadProc(Object obj)
   --- End of inner exception stack trace ---
   at Microsoft.ML.Data.TextLoader.Cursor.<ParseParallel>d__33.MoveNext()
   at Microsoft.ML.Data.TextLoader.Cursor.MoveNextCore()
   at Microsoft.ML.Data.RootCursorBase.MoveNext()
   at Microsoft.ML.Transforms.ValueToKeyMappingTransformer.Train(IHostEnvironment env, IChannel ch, ColInfo[] infos, IDataView keyData, ColumnOptionsBase[] columns, IDataView trainingData, Boolean autoConvert)
   at Microsoft.ML.Transforms.ValueToKeyMappingTransformer..ctor(IHostEnvironment env, IDataView input, ColumnOptionsBase[] columns, IDataView keyData, Boolean autoConvert)
   at Microsoft.ML.Transforms.ValueToKeyMappingEstimator.Fit(IDataView input)
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
   at GitHubIssueClassification.DecisionTree.BuildAndTrainModel(IDataView trainingDataView, IEstimator`1 pipeline) in C:\Users\OCCIDENTALIS\Source\Repos\GitHubIssueClassification\DecisionTree.cs:line 56
   at GitHubIssueClassification.DecisionTree.TrainAndMakePredictions(String FamilyName, String Description) in C:\Users\OCCIDENTALIS\Source\Repos\GitHubIssueClassification\DecisionTree.cs:line 38
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

3 REPLIES 3
Message 2 of 4

Do you have a reference to System.Runtime.CompilerServices.Unsafe and is it copied to your output directory (where your plugin dll is)? Also, all your references are for .net framework, right?

Message 3 of 4

Hi M Hannon,

I checked the System.Runtime.CompilerServices.Unsafe is being output to the same directory as my external command .dll

AFAIK all my references were to .netframeworks 4.7.2, microsoft.ml didnt have any incomaptability issues either i could compile in that framework. I did get around this problem by reading the console output. And i sent arguments to the console aswell. 

 

dll-compiler-services.png

Message 4 of 4

Hi!

I Have the same problem...
Can you explain please, how to resolve it?

Best Regards,
Bogdan.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community