Skip to content

Commit 482a9f3

Browse files
committed
Installation fix: Setup fails with exception "Value cannot be null. Parameter name: stream" on certain environments
1 parent e2e1d9a commit 482a9f3

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
###Bugfixes###
66
* IMPORTANT FIX: Memory leak leads to _OutOfMemoryException_ in application after a while
77
* Installation fix: some varchar(MAX) columns get created as varchar(4000). Added a migration to fix the column specs.
8+
* Installation fix: Setup fails with exception _Value cannot be null. Parameter name: stream_
89
* Bugfix for stock issue in product variant combinations
910
* #336 Product bundle: Upper add-to-cart button label shows wrong text
1011
* #338 Serialization exception thrown when session state mode is _StateServer_

src/Libraries/SmartStore.Core/Data/SqlFileTokenizer.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public IEnumerable<string> Tokenize()
4444
{
4545
if (this.Assembly == null)
4646
{
47-
this.Assembly = Assembly.GetCallingAssembly();
47+
this.Assembly = Assembly.GetExecutingAssembly();
4848
}
4949

5050
using (var reader = ReadSqlFile())
@@ -67,7 +67,7 @@ protected virtual StreamReader ReadSqlFile()
6767
string path = CommonHelper.MapPath(fileName);
6868
if (!File.Exists(path))
6969
{
70-
return StreamReader.Null;
70+
throw new FileNotFoundException("Sql file '{0}' not found".FormatInvariant(this.FileName));
7171
}
7272

7373
return new StreamReader(File.OpenRead(path));
@@ -78,9 +78,16 @@ protected virtual StreamReader ReadSqlFile()
7878
var asmName = assembly.FullName.Substring(0, assembly.FullName.IndexOf(','));
7979
var location = this.Location ?? asmName + ".Sql";
8080
var name = String.Format("{0}.{1}", location, fileName);
81-
var stream = assembly.GetManifestResourceStream(name);
82-
Debug.Assert(stream != null);
83-
return new StreamReader(stream);
81+
82+
try
83+
{
84+
var stream = assembly.GetManifestResourceStream(name);
85+
return new StreamReader(stream);
86+
}
87+
catch (Exception ex)
88+
{
89+
throw new FileLoadException("Error while loading embedded sql resource '{0}'".FormatInvariant(name), ex);
90+
}
8491
}
8592

8693
private string ReadNextSqlStatement(TextReader reader)

src/Libraries/SmartStore.Data/Setup/IDbMigrationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static void SqlFile(this IDbMigration migration, string fileName, Assembl
2020
{
2121
Guard.ArgumentNotEmpty(() => fileName);
2222

23-
var tokenizer = new SqlFileTokenizer(fileName, assembly ?? Assembly.GetCallingAssembly(), location);
23+
var tokenizer = new SqlFileTokenizer(fileName, assembly ?? Assembly.GetExecutingAssembly(), location);
2424
foreach (var cmd in tokenizer.Tokenize())
2525
{
2626
if (cmd.HasValue())

0 commit comments

Comments
 (0)