Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build output
/out/
/build/
/artifacts/

# Native build leftovers
CMakeCache.txt
CMakeFiles/
cmake-build-*/

# .NET build output
bin/
obj/
.vs/

# Generated scripts and logs
*.log
*.cache
42 changes: 28 additions & 14 deletions CLRNet.proj
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,23 @@
<!-- Project References -->
<ItemGroup>
<ProjectReference Include="src\CLRNetCore\CLRNetCore.vcxproj">
<Project>{12345678-1234-5678-9012-123456789012}</Project>
<Project>{8F4C5A55-2F4B-4C40-8A64-6B501B28B42C}</Project>
<Name>CLRNetCore</Name>
</ProjectReference>
<ProjectReference Include="src\CLRNetInterop\CLRNetInterop.vcxproj">
<Project>{12345678-1234-5678-9012-123456789013}</Project>
<Project>{AF9323CB-8F8C-4D9F-9E1F-349437DD9C10}</Project>
<Name>CLRNetInterop</Name>
</ProjectReference>
<ProjectReference Include="src\CLRNetSystem\CLRNetSystem.vcxproj">
<Project>{12345678-1234-5678-9012-123456789014}</Project>
<Project>{6E8E9D3E-8B1F-4C1B-BD5A-9852E5F0C8C2}</Project>
<Name>CLRNetSystem</Name>
</ProjectReference>
<ProjectReference Include="src\CLRNetHost\CLRNetHost.vcxproj">
<Project>{9F05A3F2-2F3C-436C-9B8C-045386CFB7A3}</Project>
<Name>CLRNetHost</Name>
</ProjectReference>
<ProjectReference Include="tests\CLRNetTests\CLRNetTests.vcxproj">
<Project>{12345678-1234-5678-9012-123456789015}</Project>
<Project>{4B3E8C7E-5FA6-4F16-B5E8-5E0F0C52F51F}</Project>
<Name>CLRNetTests</Name>
</ProjectReference>
</ItemGroup>
Expand All @@ -92,11 +96,15 @@
<MSBuild Projects="src\CLRNetSystem\CLRNetSystem.vcxproj" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
</Target>

<Target Name="BuildTests" DependsOnTargets="BuildCore;BuildInterop;BuildSystem">
<Target Name="BuildHost" DependsOnTargets="BuildCore;BuildInterop;BuildSystem">
<MSBuild Projects="src\CLRNetHost\CLRNetHost.vcxproj" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
</Target>

<Target Name="BuildTests" DependsOnTargets="BuildCore;BuildInterop;BuildSystem;BuildHost">
<MSBuild Projects="tests\CLRNetTests\CLRNetTests.vcxproj" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
</Target>

<Target Name="Build" DependsOnTargets="BuildCore;BuildInterop;BuildSystem;BuildTests">
<Target Name="Build" DependsOnTargets="BuildCore;BuildInterop;BuildSystem;BuildHost;BuildTests">
<Message Text="CLRNet Runtime build completed successfully!" Importance="high" />
</Target>

Expand All @@ -107,31 +115,37 @@
<MSBuild Projects="src\CLRNetCore\CLRNetCore.vcxproj" Targets="Clean" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
<MSBuild Projects="src\CLRNetInterop\CLRNetInterop.vcxproj" Targets="Clean" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
<MSBuild Projects="src\CLRNetSystem\CLRNetSystem.vcxproj" Targets="Clean" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
<MSBuild Projects="src\CLRNetHost\CLRNetHost.vcxproj" Targets="Clean" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
<MSBuild Projects="tests\CLRNetTests\CLRNetTests.vcxproj" Targets="Clean" Properties="Configuration=$(Configuration);Platform=$(Platform)" />
</Target>

<!-- Package Target -->
<Target Name="Package" DependsOnTargets="Build">
<ItemGroup>
<CoreBinaries Include="$(OutputPath)CLRNetCore.dll;$(OutputPath)CLRNetHost.exe;$(OutputPath)CLRNetJIT.dll;$(OutputPath)CLRNetGC.dll" />
<InteropBinaries Include="$(OutputPath)CLRNetInterop.dll;$(OutputPath)CLRNetWinRT.dll;$(OutputPath)CLRNetHardware.dll;$(OutputPath)CLRNetSecurity.dll" />
<SystemBinaries Include="$(OutputPath)CLRNetReplacer.exe;$(OutputPath)CLRNetHooks.dll;$(OutputPath)CLRNetCompat.dll;$(OutputPath)CLRNetSafety.dll" />
<CoreBinaries Include="$(OutputPath)CLRNetCore.dll" />
<InteropBinaries Include="$(OutputPath)CLRNetInterop.dll" />
<SystemBinaries Include="$(OutputPath)CLRNetSystem.dll" />
<HostBinaries Include="$(OutputPath)CLRNetHost.exe" />
<TestBinaries Include="$(OutputPath)CLRNetTests.exe" />
</ItemGroup>

<!-- Create deployment packages -->
<MakeDir Directories="$(OutputPath)packages\" />

<!-- Core Runtime Package -->
<Copy SourceFiles="@(CoreBinaries)" DestinationFolder="$(OutputPath)packages\CLRNet-Runtime\" />

<!-- Interop Package -->
<Copy SourceFiles="@(InteropBinaries)" DestinationFolder="$(OutputPath)packages\CLRNet-Interop\" />

<!-- System Package -->
<Copy SourceFiles="@(SystemBinaries)" DestinationFolder="$(OutputPath)packages\CLRNet-System\" />


<!-- Host Package -->
<Copy SourceFiles="@(HostBinaries)" DestinationFolder="$(OutputPath)packages\CLRNet-Host\" />

<!-- Complete Package -->
<Copy SourceFiles="@(CoreBinaries);@(InteropBinaries);@(SystemBinaries)" DestinationFolder="$(OutputPath)packages\CLRNet-Complete\" />
<Copy SourceFiles="@(CoreBinaries);@(InteropBinaries);@(SystemBinaries);@(HostBinaries);@(TestBinaries)" DestinationFolder="$(OutputPath)packages\CLRNet-Complete\" />

<Message Text="Deployment packages created in $(OutputPath)packages\" Importance="high" />
</Target>
Expand Down
192 changes: 38 additions & 154 deletions QUICK_START.md
Original file line number Diff line number Diff line change
@@ -1,172 +1,56 @@
# CLRNet Quick Start Guide

## 🚀 5-Minute Integration

Get your Windows Phone 8.1 app running with CLRNet in just 5 minutes!

### Step 1: Add CLRNet to Your Project (1 minute)

1. **Copy CLRNet Binaries**
```
YourApp/
├── CLRNet/
│ ├── CLRNetCore.dll
│ ├── CLRNetInterop.dll
│ ├── CLRNetSystem.dll
│ └── CLRNetHost.exe
└── SamplePlugin.dll
```

2. **Update Your .csproj File**
```xml
<ItemGroup>
<Content Include="CLRNet\*.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
```

### Step 2: Initialize CLRNet (2 minutes)

Add this to your `MainPage.xaml.cs`:

```csharp
using System.Runtime.InteropServices;

public sealed partial class MainPage : Page
{
[DllImport("CLRNetCore.dll")]
private static extern int CLRNet_Initialize(IntPtr config);

[DllImport("CLRNetCore.dll")]
private static extern int CLRNet_LoadAssembly(string path);

[DllImport("CLRNetCore.dll")]
private static extern int CLRNet_ExecuteMethod(string type, string method);

protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Initialize CLRNet
CLRNet_Initialize(IntPtr.Zero);
}
}
```

### Step 3: Load and Execute (1 minute)

```csharp
private void RunPlugin_Click(object sender, RoutedEventArgs e)
{
// Load your plugin
CLRNet_LoadAssembly("SamplePlugin.dll");

// Execute plugin method
CLRNet_ExecuteMethod("PluginMain", "HelloWorld");
}
```

### Step 4: Update Package Manifest (1 minute)
# Quick start

Add to `Package.appxmanifest`:
This guide walks through building the Windows Phone 8.1 runtime and host from a
fresh clone.

```xml
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>CLRNet\CLRNetCore.dll</Path>
<ActivatableClass ActivatableClassId="CLRNet.Runtime" ThreadingModel="both" />
</InProcessServer>
</Extension>
```

## ✅ That's It!
## 1. Install prerequisites

Your app now has dynamic .NET assembly loading capabilities!
- Windows 10 or 11
- Visual Studio 2019/2022 with the *Windows Phone 8.1* components
- Windows Phone 8.1 SDK (`C:\Program Files (x86)\Windows Phone Kits\8.1`)
- PowerShell 5.0+

## 🔥 Advanced Usage (Optional)
## 2. Build everything with a single command

### Plugin Interface
```csharp
public interface IMyPlugin
{
void Initialize();
string Execute(string input);
}

// In your plugin assembly
public class MyPlugin : IMyPlugin
{
public void Initialize() { /* setup */ }
public string Execute(string input) { return "Processed: " + input; }
}
```powershell
pwsh .\build-wp81.ps1 -Configuration Release -Platform ARM
```

### Dynamic Code Compilation
```csharp
// Compile C# code at runtime
string code = @"
public class RuntimeCode
{
public static string Process() { return ""Hello from runtime!""; }
}";
The script validates the SDK, locates MSBuild, and drives `CLRNet.proj` to build
all native libraries, the phone host, and the smoke-test executable. Logs are
written to `build/logs/` for troubleshooting.

// CLRNet can compile and execute this dynamically
```
## 3. Package binaries

### Game Modding System
```csharp
public class GameModLoader
{
public async Task LoadMod(string modFile)
{
await CLRNet_LoadAssembly(modFile);
CLRNet_ExecuteMethod("GameMod", "OnModLoaded");
}
}
```powershell
pwsh .\build-wp81.ps1 -Target Package -Configuration Release -Platform ARM
```

## 📱 Real-World Examples

### 1. **Business Rules Engine**
Load business logic from external assemblies without app updates.

### 2. **Plugin Marketplace**
Allow users to download and install app extensions.

### 3. **Dynamic UI Generation**
Create UI components from user-defined templates.

### 4. **Scripting System**
Enable power users to write custom scripts.

### 5. **A/B Testing Framework**
Load different feature implementations dynamically.

## 🛠️ Troubleshooting

**Runtime not initializing?**
- Check if CLRNet binaries are in your app package
- Verify Package.appxmanifest has the extension registration
Packaging copies the runtime, interop, system, host, and test artifacts into the
`build/bin/ARM/Release/packages/` folder ready to be merged into an AppX payload.

**Assembly won't load?**
- Ensure assembly targets .NET Framework 4.0
- Check file path is correct
## 4. Inspect outputs

**Method execution fails?**
- Verify class and method names are exact
- Check method is public and static
- `build/bin/ARM/<Config>/CLRNetCore.dll`
- `build/bin/ARM/<Config>/CLRNetInterop.dll`
- `build/bin/ARM/<Config>/CLRNetSystem.dll`
- `build/bin/ARM/<Config>/CLRNetHost.exe`
- `build/bin/ARM/<Config>/CLRNetTests.exe`

## 🎯 Next Steps
## 5. Run the smoke tests

1. **Read the full [Implementation Guide](IMPLEMENTATION_GUIDE.md)**
2. **Check out the [complete sample app](examples/WP81Integration/)**
3. **Explore advanced patterns and best practices**
Copy the runtime folder to a Windows Phone 8.1 device or emulator and launch
`CLRNetTests.exe`. The test harness verifies that the execution engine, security
layer, and interop managers all initialize correctly in the phone environment.

## 💡 Pro Tips
## 6. Integrate into your AppX project

- Initialize CLRNet once at app startup
- Cache loaded assemblies for better performance
- Use background threads for heavy operations
- Always handle exceptions gracefully
- Test on actual Windows Phone devices
1. Copy the binaries from `build/bin/ARM/Release/` into your app's `CLRNet/`
directory.
2. Include the host executable in the AppX manifest and add the required phone
capabilities.
3. Bundle the `packages/CLRNet-Complete/` contents alongside your managed
assemblies before creating the final XAP/AppX package.

**Happy Coding with CLRNet! 🎉**
For a deeper dive into deployment practices review `build/README.md` and the
`WP81_*` summaries in the repository root.
Loading