... так как удаление Student.number не работает
blockquote>
Student
не имеет свойстваnumber
, поэтому удалять нечего. Объекты, созданные с помощьюnew Student
, делают. Например:
function Student(name, sclass, year, number, submissionYear) { this.name = name; this.sclass = sclass; this.year = year; this.number = number; this.submissionYear = submissionYear; } var s = new Student(); console.log("number" in s); // true delete s.number; console.log("number" in s); // false
Если вы хотите создать версию
Student
, которая создает объекты безnumber
свойство, это возможно , но это плохая идея:
function Student(name, sclass, year, number, submissionYear) { this.name = name; this.sclass = sclass; this.year = year; this.number = number; this.submissionYear = submissionYear; } function NumberlessStudent() { Student.apply(this, arguments); delete this.number; } NumberlessStudent.prototype = Object.create(Student.prototype); NumberlessStudent.prototype.constructor = NumberlessStudent; var n = new NumberlessStudent(); console.log("number" in n); // false
или предпочтительно в ES2015 + с [ 118] синтаксис:
class Student { constructor(name, sclass, year, number, submissionYear) { this.name = name; this.sclass = sclass; this.year = year; this.number = number; this.submissionYear = submissionYear; } } class NumberlessStudent extends Student { constructor(...args) { super(...args); delete this.number; } } const n = new NumberlessStudent(); console.log("number" in n); // false
Это плохая идея, потому что установка наследования таким образом, экземпляры подкласса (
NumberlessStudent
) должен иметь свойства экземпляров суперкласса (Student
).
Вы можете взглянуть на mergebin , инструмент, позволяющий объединять неуправляемые и управляемые библиотеки DLL в одну сборку. System.Data.SQLite использует этот подход.
Ну, вы можете просто добавить команды для автоматического копирования необходимых DLL в правильный выходной каталог, как часть сборки обработать. Это делается в Visual Studio путем перехода к свойствам проекта.
Проект -> Свойства MyProjectName ... -> События сборки
Добавьте команды для копирования необходимых файлов в $ (TargetPath), и вы готово.
Другой вариант - просто установить текущий рабочий каталог вашего проекта (когда вы запускаете его только из Visual Studio) в каталог, в котором находятся все необходимые библиотеки DLL. Вам все равно придется вручную копировать файлы при внешнем выполнении программы, но это немного облегчит разработку.
Похоже, у вас есть две конкретные проблемы:
Для 1) вы можете использовать шаг перед сборкой в вашем C # проект для вызова пользовательской утилиты для копирования правильных файлов.
Похоже, 2) уже был дан ответ здесь, на переполнении стека .
I'm currently having a very similar problem.
One big step too meet my goal was to copy the Native .DLL into the output directory by a pre-built step in the C++/CLI project and add the linker option
/ASSEMBLYLINKRESOURCE:"$(OutDir)\Native.dll"
This writes into the resulting assembly that there is a file "Native.dll" that belongs to the assembly. Now all projects referencing that project/assembly will also copy the Native.dll around! (It should also go into the GAC if you put you're assembly there - I didn't check that).
Okay, you still have to add all depending native.dll's. I also don't know if the native DLL is found on run-time if you load the assembly via Assembly.LoadFrom() from a very different path (this is something I have to solve for my problem because our C++/CLI wrapper assembly is needed by the Visual Studio designer).
I hope this helps you a bit for you're problem.
EDIT:
Further investigations showed that the Wrapper .DLL always finds the native .DLL...that's the good thing. The bad thing is that the Visual Studio Designer copies the needed assemblies to a temporary directory (somewhere inside the user directory) when you open a form. When it copies the assemblies it ignores the linked resources and by this the native .DLL!