How to call for example the Foo method from this piece of code in 1C?

 namespace HelloWorldLibrary { public class Infrascturcture { public static string Foo() => "Hello World from C Sharp!!!"; } } 
  • 2
    First, you need to convert your code to a COM object. Then you need to register it in the system. Finally, a COM object can be created from 1C and call its method ... - Pavel Mayorov
  • one

2 answers 2

You can call any class using a wrapper.

Using .NET assemblies in 1C 7.xb 8.x. Creating an external component.

Simple example can be found here.

Using .Net classes in 1C for beginners

Your code will look like this.

 врап=новый COMОбъект("NetObjectToIDispatch45"); Infrascturcture=Врап.ПолучитьТипИзСборки("HelloWorldLibrary.Infrascturcture",ПутьКСборке_Или_Имя_ДЛЛ_Если_В_GAС); Сообщить(Infrascturcture.Foo()); 

In addition, you can use .Net events

.NET (C #) for 1C. Dynamic compilation of a wrapper class for using .Net events in 1C via Add Handler or Processing an External Event

Cross-platform use of .Net classes in 1C through Native VK. Or replacing COM with Linux

1C, Linux, Excel, Word, OpenXML, ADO, Net Core

Here are some examples.

1C Messenger for sending messages, files and data exchange between 1C users, web pages, mobile applications a la Skype, WhatsApp

Quickly create External Components in C #. Global Context Usage Examples, IAsyncEvent, IExtWndsSupport, WinForms, and WPF

.Net in 1C. Asynchronous HTTP requests, Post sending several multipart / form-data files, compressing traffic using gzip, deflate, convenient parsing of sites, etc.

.Net in 1C. On the example of using HTTPClient, AngleSharp. Convenient parsing of sites using the AngleSharp library, including authorization ala JQuery using CSS selectors. Dynamic compilation

Using TSD on WM 6 as a wireless scanner to receive data from 1C

Well, to the heap

Linq to ODATA

Code First and Linq to EF on the example of 1C version 7.7 and 8.3 part I

Code First and Linq to EF on the example of 1C version 8.3 part II

Linq to EF. Practice use. Part III

Sources and DLLs can be downloaded here http://files.rsdn.org/19608/%d0%a4%d0%b0%d0%b9%d0%bb%d1%8bNetObjectToIDispatch.zip

1C Messenger laid out separately https://yadi.sk/d/G67GAnc-nrUJ9

Treatments for the formation of Code First to bases 1C

http://files.rsdn.org/19608/CodeFirstTo1C.zip

http://files.rsdn.org/19608/CodeFirstTo83.zip