Thanks! It works perfectly. I was just wondering how to write a mod without custom objects and then you posted this ^^

And this tutorial seems to hint at the precise reason why the game crashes with some mods that use only a custom namespace name, without nesting it in an existing EA namespace (this topic ). So if you use only your own namespace, without putting it inside, lets say, Sims3.Gameplay, and don't use a static instantiator variable and a xml file to instantiate the class, then clicking on that custom object in game in buy mode will cause a crash to desktop when the game tries to create the object, because the object wasn't initialized. Because the game didn't know it was there, since the namespace of that object was not within Sims3 namespaces! Is that a correct reasoning? And the reason why nesting your namespace within EA namespaces does fix that problem, without the need of a xml file, is because the game seems to instantiate all objects by default within the Sims3 namespace, and within all child namespaces, if the objects have static components, so also the object within your nested namespace - even without the xml file. Is that correct? I simply can't live without knowing, why exactly something crashes and why a fix works, like in that case.

Anyway, awesome, informative tutorial.

"The past tempts us, the present confuses us and the future frightens us.. and our lives slip away, moment by moment, lost in that vast, terrible in-between"

And this tutorial seems to hint at the precise reason why the game crashes with some mods that use only a custom namespace name, without nesting it in an existing EA namespace{...}

I don't think it does.

Quote:

then clicking on that custom object in game in buy mode will cause a crash to desktop when the game tries to create the object, because the object wasn't initialized.{...}

No, the initializing of the static fields of a class is something that gets enforced by the framework. Initializing an object, aka an instance of the class, is the job of the non-static constructor(s) and thus completely unrelated. Since script classes for object mods need to be derived from GameObject, there's actually a shitload of other differences BTW.

What is actually different for a buymode object that already existed in the town when you loaded the game and an object that the game tries to create when you click on the thumbnail in buymode? Fetching the mesh, finding the assembly, and instantiating an object aren't different. That much seems certain. The BuildBuyMode stuff is mind-meltingly massive and wide-spread. Last time I browsed that code, I couldn't even find the point where the actual object gets created.

In the thread you linked, twallan speculated that the game might use the script class as a lookup value for some store stuff. That might be the case. All we know for certain is that the exception gets thrown in the unmanaged code, and that the devs at that point probably most definitely didn't safe-guard their code against "unexpected results".

Quote:

I simply can't live without knowing, why exactly something crashes and why a fix works, like in that case.

Then it'd probably be best to get yourself an EAxian coder (kidnapping might help) and hook him up to a car battery until he spills the beans. The unmanaged code is terra incognita for modders. The chance that we ever learn what is causing the crashing issue is less than miniscule.

First off thanks for this tutorial. I'm wondering if during the first step, when you extract the game libraries, you should extract them from only the base game .packages or from the latest EP .packages?

I'm wondering if during the first step, when you extract the game libraries, you should extract them from only the base game .packages or from the latest EP .packages?

Doesn't matter. As long as base game and EPs are on the same related patch level (you can check the code version of the S3SA resources in S3PE - current version is 0.2.0.128), the libraries are the same.

At the beginning of your tutorial, there is a link leading to another page regarding game-compatible VS projects. Step 4 of this tutorial mentioned these .dll files, along with a screenshot. I also Google'd them and ended up onto another page that again mentioned them.

I have another question; I have nothing to worry about this warning, right?

I have another question; I have nothing to worry about this warning, right?

Damn, I was kinda waiting for that one. It's a known bug in Visual Studio that the "Do not reference mscorlib" thing does nothing. In VS2008 it at least worked most of the times, but in VS2010 it doesn't seem to do anything at all anymore.

I don't know whether projects compiled against the .NET mscorlib will work in the game; you're welcome to try. The only other "solution" is to go back to Visual Studio 2008.

But I'm not yet done with the project, because it won't produce the
appropriate .dll file. Everytime I build the solution, I get these errors:
As you can tell, I'm practically new with all of these; I felt all along that
this is somehow not really my calling. But what the heck, it's worth a shot.

I have it typed in correctly. I'm sorry, I should have known better and posted screenshots of my project instead of having you blindly guess the problem.

Anyway, I found out that the cause was actually line 4 of AssemblyInfo.cs. It turns out that I simply typed in "Sims3.SimIFace;" leaving out the word 'using' before it. I guess I've gotten confused in your tutorial because the word 'using' is in a different font than "Sims3.SimIFace;". So I only copy-pasted the latter. If that makes sense. I fixed it.

Now, I'm getting another error; I think it's referring to that class called 'object' down on page 18:

I guess I've gotten confused in your tutorial because the word 'using' is in a different font than "Sims3.SimIFace;".

Fixed.

Quote:

Now, I'm getting another error; I think it's referring to that class called 'object' down on page 18:{...}

That means that VisualStudio actually did derefence mscorlib, or at least uses the /nostdlib compiler option. Try to add the mscorlib from TS3 once more or, if that doesn't work, untick the "Do not reference mscorlib" thing again.

I use vs2010 and got it to work by editing the csproj. You just need to change the path to mscorlib from the default
to wherever you put the sims3 version of mscorlib. Or, if you don't have the reference to mscorlib in the .csproj file,
just paste the below in the <ItemGroup> where all the other <Reference Include= lines are located and edit the
<HintPath> as needed.

That means that VisualStudio actually did derefence mscorlib, or at least uses the /nostdlib compiler option. Try to add the mscorlib from TS3 once more or, if that doesn't work, untick the "Do not reference mscorlib" thing again.

I unticked the, "Do not reference mscorlib" checkbox, built the project, and it worked. I thought to myself that the default mscorlib file couldn't possibly work for TS3, otherwise there wouldn't be any point as to why we're even using the TS3 version of mscorlib. But to my surprise, the mod did work in-game. Is this normal? Or are there going to be side effects? Why are we using the TS3 version when the default mscorlib works out just fine?

Quote:

Originally Posted by lenglel

I use vs2010 and got it to work by editing the csproj. You just need to change the path to mscorlib from the default
to wherever you put the sims3 version of mscorlib. Or, if you don't have the reference to mscorlib in the .csproj file,
just paste the below in the <ItemGroup> where all the other <Reference Include= lines are located and edit the
<HintPath> as needed.

How do I change the reference path within the .csproj?
Where is this "<ItemGroup>" and all of those other codes?

Please forgive me for asking a lot of questions but I'm really new to VS and all of these C sharp talks, so I find it very difficult to keep up.
I just started learning as soon as I posted in this thread(3 days ago). Any new information would go a long way.

And before I forget, thank you guys for helping me with my first script mod.

Why are we using the TS3 version when the default mscorlib works out just fine?

The mscorlib from TS3 is not the .NET mscorlib that Visual Studio uses by default; it's an altered mscorlib from the MONO portable framework. MONO implements .NET 2.0, so a library compiled against the .NET mscorlib should work ... most of the times. I honestly don't know in which ways the MONO mscorlib might differ or what it might not implement or what the EAxian devs stripped from it (apart from direct file access).

So, yeah, it will probably work if you don't go crazy and if you ever do something the TS3 mscorlib doesn't support, the compiled library hopefully won't link and stall your game instead of causing subtle borkedness. I for one would prefer to get Visual Studio to reference the TS3 mscorlib or at least manually compile against it.

Vondure: Just use a text editor like notepad++ to open and edit the file with the .csproj
extension. It's in the first subfolder of your projects folder in the vs2010 projects directory.
You'd need to change the path to point to wherever you extracted the ts3 mscorlib.

The mscorlib from TS3 is not the .NET mscorlib that Visual Studio uses by default; it's an altered mscorlib from the MONO portable framework. MONO implements .NET 2.0, so a library compiled against the .NET mscorlib should work ... most of the times. I honestly don't know in which ways the MONO mscorlib might differ or what it might not implement or what the EAxian devs stripped from it (apart from direct file access).

So, yeah, it will probably work if you don't go crazy and if you ever do something the TS3 mscorlib doesn't support, the compiled library hopefully won't link and stall your game instead of causing subtle borkedness. I for one would prefer to get Visual Studio to reference the TS3 mscorlib or at least manually compile against it.

I will try to do that. I sure hope it doesn't crash my game. So far it's working alright for this particular mod, but I'll keep that in mind.

Quote:

Originally Posted by lenglel

Vondure: Just use a text editor like notepad++ to open and edit the file with the .csproj
extension. It's in the first subfolder of your projects folder in the vs2010 projects directory.
You'd need to change the path to point to wherever you extracted the ts3 mscorlib.

It might be correct for your setup, but mine has a lot of stuff yours doesn't.
I've got my simcore stuff outside the vs2010 hierarchy, that's why all my
hintpaths start with "..\..\..\..\s3modprojects\simcore\

The PropertyGroup sections get set up from within vs2010 when you
select your project's properties. The first ItemGroup is the source files
and the second is the references from the using statements at the top
of the source file. That's where the reference to the sims 3 version of
mscorlib goes.

Damn, I was kinda waiting for that one. It's a known bug in Visual Studio that the "Do not reference mscorlib" thing does nothing. In VS2008 it at least worked most of the times, but in VS2010 it doesn't seem to do anything at all anymore.

You can use Visual C# Express. You just have to manually edit the .csproj file to make it see the right one.

For me, I have extract the necessary dlls to My Documents\Visual Studio 2010\Sims3dll. After you have told it not to use mscorlib (not totally useless checkmark), you exit Visual C# 2010. Then (assuming for this your project is named MyScript) you open the My Documents\Visual Studio 2010\MyScript\MyScript\MyScript.csproj with something like Notepad or Notepad++.